Skip to content

cards: a social card for every page, drawn at build time - #121

Merged
aledbf merged 1 commit into
mainfrom
infra-cards
Nov 19, 2026
Merged

aledbf merged 1 commit into
mainfrom
infra-cards

Conversation

@aledbf

@aledbf aledbf commented Nov 19, 2026

Copy link
Copy Markdown
Member

Every page shared public/og.png as its link preview. Now each page gets its own card, drawn by the build from what the page already has: its topic (src/lib/nav.mjs), its title and its description. No card is drawn by hand, and the generated reference pages get one too.

  • src/lib/card.ts: the card, 1200x630, in brand's dark-panel colours (read from src/styles/brand-tokens.css, which task reference copies from brand), IBM Plex from the fontsource packages the site already serves, and the organization's mark. satori lays out the text and draws each glyph as a path, so nothing needs a font installed where the site builds; sharp, already a dependency, writes the PNG. One new dependency: satori 0.63.2, installed through sfw.
  • src/pages/cards/[...slug].png.ts: one card per page but the landing page, at /cards/<page>.png.
  • Head.astro: og:image and twitter:image per page, absolute from the configured site and base (checked with SITE_URL=https://spinbox.dev BASE_PATH=/ too). The landing page and the 404 keep og.png, which is the better picture there. The global og:image in astro.config.mjs goes.
  • nav.mjs: topicOf(id), which fails the build for a page in no group.
  • README: the paragraph for it.

Build time, cold (no .astro cache, three runs each): about 3.4 s before, 5.4 s after, for 100 cards (~20 ms each). dist/ grows by about 4.7 MB.

go tool task check passes.

🤖 Generated with Claude Code

Every page shared public/og.png as its link preview. src/pages/cards/ now draws
one card per page, the generated reference pages included, from its topic in
nav.mjs, its title and its description, in brand's colours and IBM Plex
(satori lays out the text as paths, so no font has to be installed where the
site builds; sharp, already a dependency, writes the PNG). Head.astro names it
as og:image and twitter:image, by the configured site and base; the landing
page and the 404 keep og.png.

A cold build goes from about 3.4 s to 5.4 s for the hundred cards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aledbf
aledbf merged commit 9ff4b66 into main Nov 19, 2026
2 checks passed
@aledbf
aledbf deleted the infra-cards branch November 19, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant