Repository navigation
Commit 36da187
feat: OG image generation on Workers
Four Satori-backed endpoints — /api/og/{default,blog,podcast,person}.png
— recovered from the pre-Next Astro app along with the two Inter TTFs and
the rawFonts Vite plugin that inlines them as Uint8Array (Workers has no
filesystem for Satori to read from).
The load-bearing part of that recovery is its workaround, kept verbatim
with its explanation: workers-og parses HTML with HTMLRewriter, which
corrupts the HTML-to-VDOM conversion on Workers, so these build React
element objects and hand them to ImageResponse directly.
Wired in as a FALLBACK, not a replacement. Where a document has a cover
image the card is still that image, byte-for-byte what the Next app
served. Documents without one previously emitted no og:image at all;
those now get a generated card. The home page and section indexes get one
too.
Verified on real workerd under `wrangler dev`, not `astro dev` — all four
endpoints return valid 1200x630 PNGs, and the rendered images were
inspected rather than just status-checked. That caught the one visual
defect: the recovered logo used a cat emoji, and Satori renders only
glyphs present in the fonts it is given, so it came out as a tofu box on
every card. Replaced with a monogram tile in the brand gradient.
Brand tokens are literal hex rather than the CSS custom properties the
rest of the site uses: Satori resolves neither var() nor oklch().
Font imports are now typed via a `*.ttf` module declaration, since Astro's
own asset typings declare them as URL strings — the opposite of what the
rawFonts plugin actually returns. That removes the `@ts-ignore` pair and
the `as any` in loadFonts.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HZ4S1uTJwFdbv3A6PHWfw21 parent c5cc7a3 commit 36da187
21 files changed
Lines changed: 875 additions & 3 deletions
File tree
- apps/site
- src
- assets/fonts
- layouts
- lib
- pages
- api/og
- author
- blog
- guest
- podcasts
- podcast
- post
- sponsor
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
Binary file not shown.
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
3 | 22 | | |
4 | 23 | | |
5 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
| |||
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| 50 | + | |
44 | 51 | | |
45 | 52 | | |
46 | 53 | | |
47 | 54 | | |
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
51 | 61 | | |
52 | 62 | | |
53 | 63 | | |
| |||
67 | 77 | | |
68 | 78 | | |
69 | 79 | | |
70 | | - | |
| 80 | + | |
71 | 81 | | |
72 | 82 | | |
73 | 83 | | |
| |||
0 commit comments