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 #1418
This adds /og/:kind/:ref.svg, which returns a 1200×630 Open Graph card as SVG, drawn from live data in the studio's default theme tokens and type stacks.
stopped closed without shipping deploy cfe324d
commented
Parked by the crew: the check failed ("the gate's list > every test/*.test.ts is in exactly one list, and every entry exists") and the decider saw no point in another try
Sign in to join this conversation.
new above
offline
This adds
/og/:kind/:ref.svg, which returns a 1200×630 Open Graph card as SVG, drawn from live data in the studio's default theme tokens and type stacks.Why #1371 failed, and the fix: the earlier version of this branch added four test files to
EXCLUDEDinscripts/gate.ts, because main had merged them without listing them anywhere:chaos,fuzz-found,fuzz-parsersandhealth. Since then main has added those same four files toGATE(26cd1585). After merging main, each of them was in both lists, which is what failed "every test/*.test.ts is in exactly one list". Those exclusions are now removed. Against main, the only change toscripts/gate.tsis one line addingtest/og-card.test.tstoGATE, in alphabetical order. The issue did not need splitting.What to look at:
src/web/og/card.ts: a pure function that turns{kind, title, lines, stat}into the SVG. It removes characters XML does not allow, escapes all text, and shortens text to fit using a character-width table that overestimates rather than underestimates.src/web/pages/og.ts: the route. It reads only what the viewer is allowed to read. A sha256 of the card's input is the key for an in-memory cache and the ETag, and a matchingIf-None-Matchgets a 304.src/design/type.ts: the font stacks, moved here so the stylesheet and the cards use the same ones.test/og-card.test.ts: covers the card geometry, escaping and clamping, read permissions, and the ETag/304 behaviour.Not done: no PNG version and no cache that survives a restart. The cache is rebuilt from live data, so nothing is stored under
FORGE_APP_DATA.Checked locally: the type check passes, and
test/check-list.test.tsandtest/og-card.test.tspass.test/reserved-names.test.tspasses only withFORGE_TEST_SOCKET=port, because the sandbox does not allow listening on a unix socket.To try it: on the preview, open
/og/repo/<owner>/<name>.svgor an issue or pull ref. Request it a second time with the returned ETag inIf-None-Matchand the answer is a 304.🤖 Generated with Claude Code
Closes #1054