gitlogue 0.9.0

A Git history screensaver - watch your code rewrite itself
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
import satori from 'satori';
import { Resvg } from '@resvg/resvg-js';
import fs from 'fs/promises';
import { fileURLToPath } from 'url';
import path from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

async function fetchFontFromGoogleFonts(fontFamily) {
  const cssUrl = `https://fonts.googleapis.com/css2?family=${fontFamily.replace(/\s+/g, '+')}:wght@700&display=swap`;
  const cssResponse = await fetch(cssUrl);
  const cssText = await cssResponse.text();

  const match = cssText.match(/url\((https:\/\/fonts\.gstatic\.com\/[^)]+\.ttf)\)/);
  if (!match) {
    throw new Error(`Could not find font URL for ${fontFamily}`);
  }

  const fontUrl = match[1];
  const fontResponse = await fetch(fontUrl);
  const arrayBuffer = await fontResponse.arrayBuffer();
  return Buffer.from(arrayBuffer);
}

async function generateOGP() {
  const width = 1200;
  const height = 630;

  // Download fonts from Google Fonts
  console.log('Downloading Crimson Text...');
  const crimsonTextData = await fetchFontFromGoogleFonts('Crimson Text');
  console.log('Downloading Lora...');
  const loraData = await fetchFontFromGoogleFonts('Lora');

  // Code snippet with syntax highlighting
  const codeLines = [
    { num: '174', code: '    ', color: '#E5E5E5' },
    { num: '175', code: '    pub fn new(config: Config) -> Self {', color: '#E5E5E5' },
    { num: '176', code: '        Self { engine: Engine::new(config) }', color: '#E5E5E5' },
    { num: '177', code: '    }', color: '#E5E5E5' },
    { num: '178', code: '    ', color: '#E5E5E5' },
    { num: '179', code: '-   pub fn load(&mut self, meta: Metadata) {', color: '#E06C75', bg: '#3F1F1F' },
    { num: '180', code: '+   pub fn load(&mut self, meta: Metadata) -> Result<()> {', color: '#89E051', bg: '#1F3F1F' },
    { num: '181', code: '        self.metadata = Some(meta.clone());', color: '#E5E5E5' },
    { num: '182', code: '        self.engine.load(meta)?;', color: '#E5E5E5' },
    { num: '183', code: '+       self.validate_state()?;', color: '#89E051', bg: '#1F3F1F' },
    { num: '184', code: '        Ok(())', color: '#E5E5E5' },
    { num: '185', code: '    }', color: '#E5E5E5' },
    { num: '186', code: '    ', color: '#E5E5E5' },
    { num: '187', code: '    pub fn render(&mut self) -> Result<()> {', color: '#E5E5E5' },
    { num: '188', code: '        self.engine.render()', color: '#E5E5E5' },
  ];

  const svg = await satori(
    {
      type: 'div',
      props: {
        style: {
          width: '100%',
          height: '100%',
          display: 'flex',
          backgroundColor: '#0C0C0F',
        },
        children: [
          // Left side: Title and info (40%)
          {
            type: 'div',
            props: {
              style: {
                width: '40%',
                height: '100%',
                display: 'flex',
                flexDirection: 'column',
                justifyContent: 'center',
                alignItems: 'flex-start',
                padding: '60px',
                gap: 30,
              },
              children: [
                // Title
                {
                  type: 'div',
                  props: {
                    style: {
                      fontSize: 76,
                      fontWeight: 700,
                      fontFamily: 'Crimson Text',
                      color: '#E5E5E5',
                      letterSpacing: '-0.02em',
                    },
                    children: 'gitlogue',
                  },
                },
                // Tagline
                {
                  type: 'div',
                  props: {
                    style: {
                      fontSize: 24,
                      fontFamily: 'Lora',
                      color: '#A0A0A0',
                      lineHeight: 1.5,
                    },
                    children: 'Cinematic Git commit replay for your terminal',
                  },
                },
                // Subcopy
                {
                  type: 'div',
                  props: {
                    style: {
                      fontSize: 18,
                      fontFamily: 'Lora',
                      color: '#61AFEF',
                      fontStyle: 'italic',
                    },
                    children: 'Watch your code history come alive.',
                  },
                },
                // Use cases
                {
                  type: 'div',
                  props: {
                    style: {
                      display: 'flex',
                      flexDirection: 'column',
                      gap: 6,
                      marginTop: 30,
                    },
                    children: [
                      {
                        type: 'div',
                        props: {
                          style: {
                            fontSize: 16,
                            fontFamily: 'Lora',
                            display: 'flex',
                            gap: 6,
                          },
                          children: [
                            { type: 'div', props: { style: { color: '#7AA2F7' }, children: '▸ Screensaver' } },
                            { type: 'div', props: { style: { color: '#565F89' }, children: '— Ambient coding display' } },
                          ],
                        },
                      },
                      {
                        type: 'div',
                        props: {
                          style: {
                            fontSize: 16,
                            fontFamily: 'Lora',
                            display: 'flex',
                            gap: 6,
                          },
                          children: [
                            { type: 'div', props: { style: { color: '#9ECE6A' }, children: '▸ Education' } },
                            { type: 'div', props: { style: { color: '#565F89' }, children: '— Visualize code evolution' } },
                          ],
                        },
                      },
                      {
                        type: 'div',
                        props: {
                          style: {
                            fontSize: 16,
                            fontFamily: 'Lora',
                            display: 'flex',
                            gap: 6,
                          },
                          children: [
                            { type: 'div', props: { style: { color: '#E0AF68' }, children: '▸ Presentations' } },
                            { type: 'div', props: { style: { color: '#565F89' }, children: '— Replay commit histories' } },
                          ],
                        },
                      },
                      {
                        type: 'div',
                        props: {
                          style: {
                            fontSize: 16,
                            fontFamily: 'Lora',
                            display: 'flex',
                            gap: 6,
                          },
                          children: [
                            { type: 'div', props: { style: { color: '#BB9AF7' }, children: '▸ Content Creation' } },
                            { type: 'div', props: { style: { color: '#565F89' }, children: '— Record with VHS/asciinema' } },
                          ],
                        },
                      },
                      {
                        type: 'div',
                        props: {
                          style: {
                            fontSize: 16,
                            fontFamily: 'Lora',
                            display: 'flex',
                            gap: 6,
                          },
                          children: [
                            { type: 'div', props: { style: { color: '#7DCFFF' }, children: '▸ Desktop Ricing' } },
                            { type: 'div', props: { style: { color: '#565F89' }, children: '— Living terminal decoration' } },
                          ],
                        },
                      },
                    ],
                  },
                },
                // GitHub URL
                {
                  type: 'div',
                  props: {
                    style: {
                      fontSize: 16,
                      fontFamily: 'Lora',
                      color: '#4B5263',
                      marginTop: 'auto',
                    },
                    children: 'github.com/unhappychoice/gitlogue',
                  },
                },
              ],
            },
          },
          // Right side: Terminal box with TUI layout (60%)
          {
            type: 'div',
            props: {
              style: {
                width: '60%',
                height: '100%',
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                padding: '50px',
                backgroundColor: '#0C0C0F',
              },
              children: [
                // Terminal box wrapper
                {
                  type: 'div',
                  props: {
                    style: {
                      width: '100%',
                      height: '100%',
                      backgroundColor: '#1A1B26',
                      borderRadius: 8,
                      overflow: 'hidden',
                      display: 'flex',
                      flexDirection: 'column',
                    },
                    children: [
                      // Top row: FileTree | Editor
                      {
                        type: 'div',
                        props: {
                          style: {
                            display: 'flex',
                            height: '75%',
                          },
                          children: [
                            // FileTree (left)
                            {
                              type: 'div',
                              props: {
                                style: {
                                  width: '25%',
                                  backgroundColor: '#16161E',
                                  padding: '15px',
                                  display: 'flex',
                                  flexDirection: 'column',
                                  gap: 4,
                                  fontFamily: 'JetBrains Mono',
                                  fontSize: 11,
                                  color: '#565F89',
                                },
                                children: [
                                  { type: 'div', props: { style: { color: '#7AA2F7' }, children: 'src/' } },
                                  { type: 'div', props: { style: { color: '#9ECE6A', paddingLeft: 10 }, children: '~ ui.rs +28 -7' } },
                                  { type: 'div', props: { style: { paddingLeft: 10, color: '#565F89' }, children: '  animation.rs' } },
                                  { type: 'div', props: { style: { paddingLeft: 10, color: '#565F89' }, children: '  config.rs' } },
                                  { type: 'div', props: { style: { paddingLeft: 10, color: '#565F89' }, children: '  git.rs' } },
                                  { type: 'div', props: { style: { color: '#7AA2F7', marginTop: 4 }, children: 'Cargo.toml' } },
                                  { type: 'div', props: { style: { color: '#7AA2F7' }, children: 'README.md' } },
                                ],
                              },
                            },
                            // Editor (right)
                            {
                              type: 'div',
                              props: {
                                style: {
                                  width: '75%',
                                  backgroundColor: '#1A1B26',
                                  padding: '15px',
                                  display: 'flex',
                                  flexDirection: 'column',
                                  gap: 1,
                                  fontFamily: 'JetBrains Mono',
                                  fontSize: 11,
                                },
                                children: codeLines.map(line => ({
                                  type: 'div',
                                  props: {
                                    style: {
                                      display: 'flex',
                                      backgroundColor: line.bg || 'transparent',
                                      paddingLeft: 4,
                                      paddingRight: 4,
                                    },
                                    children: [
                                      {
                                        type: 'div',
                                        props: {
                                          style: {
                                            color: '#3B4261',
                                            marginRight: 12,
                                            width: 30,
                                            textAlign: 'right',
                                            fontSize: 10,
                                          },
                                          children: line.num,
                                        },
                                      },
                                      {
                                        type: 'div',
                                        props: {
                                          style: {
                                            color: line.color,
                                            whiteSpace: 'pre',
                                          },
                                          children: line.code,
                                        },
                                      },
                                    ],
                                  },
                                })),
                              },
                            },
                          ],
                        },
                      },
                      // Bottom row: Commit meta | Terminal
                      {
                        type: 'div',
                        props: {
                          style: {
                            display: 'flex',
                            height: '25%',
                            borderTop: '1px solid #3B4261',
                          },
                          children: [
                            // Commit metadata (left)
                            {
                              type: 'div',
                              props: {
                                style: {
                                  width: '25%',
                                  backgroundColor: '#16161E',
                                  padding: '15px',
                                  display: 'flex',
                                  flexDirection: 'column',
                                  gap: 6,
                                  fontFamily: 'JetBrains Mono',
                                  fontSize: 10,
                                  color: '#9AA5CE',
                                },
                                children: [
                                  { type: 'div', props: { style: { color: '#E0AF68' }, children: 'hash: f16f674' } },
                                  { type: 'div', props: { style: { color: '#9AA5CE' }, children: 'author: Yuji Ueki' } },
                                  { type: 'div', props: { style: { color: '#565F89', fontSize: 9 }, children: 'date: 2025-11-09' } },
                                  { type: 'div', props: { style: { color: '#565F89', fontSize: 9 }, children: '      16:51:33' } },
                                  { type: 'div', props: { style: { color: '#7AA2F7', marginTop: 8 }, children: 'feat: implement' } },
                                  { type: 'div', props: { style: { color: '#7AA2F7' }, children: 'input handling' } },
                                ],
                              },
                            },
                            // Terminal (right)
                            {
                              type: 'div',
                              props: {
                                style: {
                                  width: '75%',
                                  backgroundColor: '#1A1B26',
                                  padding: '15px',
                                  display: 'flex',
                                  flexDirection: 'column',
                                  gap: 3,
                                  fontFamily: 'JetBrains Mono',
                                  fontSize: 10,
                                  color: '#565F89',
                                },
                                children: [
                                  { type: 'div', props: { style: { color: '#9ECE6A' }, children: '~ time-travel 2025-11-09 16:51:33' } },
                                  { type: 'div', props: { style: { color: '#9AA5CE' }, children: 'Compressing digital dreams: 100%' } },
                                  { type: 'div', props: { style: { color: '#9AA5CE' }, children: 'Signing with invisible ink: done.' } },
                                  { type: 'div', props: { style: { color: '#9ECE6A', marginTop: 3 }, children: '3a62bb4..3a62bb4  SUCCESS' } },
                                  { type: 'div', props: { style: { color: '#7AA2F7' }, children: 'Arrived at 2025-11-09 16:51:33' } },
                                ],
                              },
                            },
                          ],
                        },
                      },
                    ],
                  },
                },
              ],
            },
          },
        ],
      },
    },
    {
      width,
      height,
      fonts: [
        {
          name: 'Crimson Text',
          data: crimsonTextData,
          weight: 700,
          style: 'normal',
        },
        {
          name: 'Lora',
          data: loraData,
          weight: 400,
          style: 'normal',
        },
        {
          name: 'JetBrains Mono',
          data: await fs.readFile('/home/owner/.local/share/fonts/jetbrains-mono/JetBrainsMono-Regular.ttf'),
          weight: 400,
          style: 'normal',
        },
      ],
    }
  );

  // Convert SVG to PNG
  const resvg = new Resvg(svg);
  const pngData = resvg.render();
  const pngBuffer = pngData.asPng();

  // Save the image
  const outputPath = path.join(__dirname, '../../docs/assets/ogp.png');
  await fs.writeFile(outputPath, pngBuffer);

  console.log(` OGP image generated: ${outputPath}`);
  console.log(`   Size: ${width}x${height}px`);
  console.log(`   ""`);
}

generateOGP().catch(console.error);