Public: anyone can read this; the crew can change it.
OG cards as SVG: `/og/:kind/:ref.svg` composed from live data with the studio's tokens, cached by input hash #1008
GET /og/:kind/:ref.svg now serves 1200×630 SVG cards for app, repo, issue, pull and run, with zero new dependencies and forge.json untouched. The new tests, reserved-names and check-list pass (45 tests) and tsc --noEmit is clean. I did not run the whole suite.
stopped closed without shipping deploy 8384404
Sign in to join this conversation.
new above
offline
GET /og/:kind/:ref.svgnow serves 1200×630 SVG cards for app, repo, issue, pull and run, with zero new dependencies andforge.jsonuntouched. The new tests,reserved-namesandcheck-listpass (45 tests) andtsc --noEmitis clean. I did not run the whole suite. The pull kind has no route test (below). The tests only ran with the sandbox off, because it refuses the unix-socket listen the server needs.What changed
src/web/og/card.ts: a purerenderCard({kind, title, lines, stat}). Colours come from the Porcelain tokens insrc/design/themes.ts. The font is the stylesheet's system stack, copied in becausesrc/designhas no type tokens. Text is stripped of XML-illegal characters, clamped to the width it is drawn in with an ellipsis, then escaped. The clamp uses a deliberately generous per-character width estimate rather than real font metrics.src/web/pages/og.ts: resolves the ref to a card, hashes the inputs with sha256, and keeps the SVG in an in-memory map (500 entries). TheETagis that hash,Cache-Controlispublic, max-age=300, and a matchingIf-None-Matchgets a 304.src/http/server.ts: the route, registered above/:owner.ogis added to the reserved names, because the existing test requires every top-level route to be reserved.scripts/gate.ts: addstest/og-card.test.tsto the gate.Ref format
owner~name.owner~name~N.For example,
/og/issue/alice~open~1.svg.Visibility
public-cacheable and must not carry private data.Tests (
test/og-card.test.ts)<script>,&, 500 characters) is escaped and clamped.ETagmatch returns 304.Left out
og:imagemeta tags that point at these URLs.Try it
bun run src/main.ts, then open/og/repo/<owner>~<name>.svgfor any public repo.bun test test/og-card.test.ts.🤖 Generated with Claude Code
Closes #567