Repository navigation
feat(site): pre.dev share card on every docs page - #62
Merged
Merged
Conversation
Every page's og:image and twitter:image is now the one pre.dev card design (site/lib/share-card.mjs, an exact copy of the card spec), filled with the page's section, title and description and the docs.pre.dev/<page> address. - app/og/[...slug]/route.ts draws each card at build time with satori 0.33.4 and @resvg/resvg-js (fitCard measures with the same satori), replacing the next/og ImageResponse card. checkCard() failures stop the build. - Cards live at /og/<page>/<hash>.png. The hash is sha256 of CARD_DESIGN and the card's inputs, so a changed title, description, section or design gets a new URL. The Worker serves hashed cards as immutable; /og/<page>/image.png keeps answering with the current card. - Tags: og:image with type, width, height and alt (cardAlt), twitter:image with alt, twitter:card summary_large_image, og:site_name pre.dev, og:title the page title alone. - Section: the page's docs.json group, at most two levels below its tab. A page without a description uses its first paragraph. - check:out fails a page without its card, its 1200x630 PNG, alt text or the full tag set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every docs page link now unfurls with the one pre.dev share card, showing that page's section, title and description.
How cards are made
site/lib/share-card.mjsis an exact copy of the card spec (header kept).site/lib/share-card.d.mtstypes it.site/lib/og-card.tsbuilds each page's card:pre.dev · Docs · <section>fit: true)pre.dev documentationanddocs.pre.dev/<page>site/app/og/[...slug]/route.tsdraws the cards at build time with satori 0.33.4 and@resvg/resvg-js2.6.2, both added as devDependencies. These are the versions the spec was verified with.fitCardmeasures with that same satori. The route replaces thenext/ogImageResponse card, which bundles satori 0.25 and gives no satori to measure with. A card that failscheckCard()stops the build.docs.json, at most two levels below its tab. The AI Gateway endpoint pages read "AI Gateway reference" and the payments pages read "Payments". A section too long for the eyebrow line fails the build.npm run checkalready requires one.Cache busting
/og/<page>/<hash>.png. The hash is the first 10 hex characters of the sha256 ofCARD_DESIGNplus the card's inputs.og:imageandtwitter:imagepoint at it.max-age=31536000, immutable./og/<page>/image.png, the old address, still answers with the current card, so earlier unfurls keep their image.Tags on every page
og:image(+:type,:width1200,:height630,:alt),twitter:cardsummary_large_image,twitter:image(+:alt),og:site_namepre.dev, andog:titleset to the page title alone. Both alt tags arecardAlt(card).CI gate
npm run check:out(the "Docs site" workflow) now fails any nav page when:og:imageis missing, or is not/og/<page>/<hash>.pngtwitter:cardis not summary_large_image, ortwitter:imagediffers fromog:imageog:site_nameis wrong, orog:titleis more than the page titleChecked locally
npm run check: passed, 103 pages.npm run build: 103 share cards.check:out: 103 pages, 103 share cards, 79 redirects, 1350 internal links OK.check:worker: passed.tsc --noEmit: passed.parity.mjsthroughwrangler dev: 404 URL checks, no differences.check:outfail on both.🤖 Generated with Claude Code