Files
hoelee-blog/scripts/og-gen
hoelee 541b00c958
Deploy / build (push) Successful in 19s
post(tutorials): does re-encoding to HEVC actually shrink your files? I measured it (EN+ZH) + og/banner
Measured on real files with quality held fixed (SSIM vs the source, harness self-tested at 1.0000):
hevc_nvenc cq27 produced 115% and 119% of the source video bitrate on two of three files while cq30/31
landed 51-84%; libx265 crf26 landed 33.7/56.7/67.0% at min SSIM 0.988-0.993, i.e. 10-22% smaller than
NVENC at matched quality. Two sources with identical bpp (0.0437) shrank 49% vs 17%, so bpp classifies
files but does not predict the ratio. Notes the audio floor (a 33.7% video stream still yields a 53%
file because AAC dominates what is left) and why VP9/AV1 sources have no headroom (copy the video).
2026-10-08 05:19:27 +08:00
..

og-gen — per-post OG image generator

Generates a branded 1200×630 social-share image for a blog post, matching the site's cobalt-blue #295cff branding, the logo-square.png mark, and the "terminal / debugging" visual style.

Usage

node scripts/og-gen/generate.mjs <post-slug>

Reads frontmatter (title, category, tags) from src/content/posts/<slug>.md, fills template.html, renders with headless Chrome, and writes public/og/<slug>.png.

The post's frontmatter needs ogImage: /og/<slug>.png so the blog serves it (layout already renders og:image + width/height; PostList shows it as a card thumbnail).

Customizing the terminal box

Each post shows a "terminal" panel (the red error / green fix lines). Add an entry keyed by slug in TERMINALS inside generate.mjs, using these tokens:

<div class="line"><span class="prompt">$</span><span class="cmd">command</span></div>
<div class="line"><span class="prompt">&nbsp;</span><span class="err">error line</span></div>
<div class="line"><span class="prompt">$</span><span class="cmd">fix</span><span class="fix">→ done ✓</span></div>

No entry → a generic default terminal.

Requirements

  • Google Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe (override with CHROME_PATH env var).
  • Node 20+.

Notes

  • PNG (not JPG) is intentional: for flat UI/terminal art, PNG is smaller and sharper than JPG (see commit history).
  • The logo-square.png referenced lives at public/logo-square.png.