feat(seo): social preview images for the GitHub repositories - #17
Merged
Merged
Conversation
GitHub has no API for a repository's social preview, so the image is uploaded by hand. Build it with the site's share cards rather than by hand elsewhere: the same card at the 1280x640 GitHub recommends, one each for ThinkWatch-Lite, ThinkWatch-Core, ThinkWatch and the organization's .github profile, published at /og/github/<card>.png. The name and the labels are the site card's; the line under the name follows each repository's description on GitHub. The site's own cards come out byte for byte the same. 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.
Summary
GitHub has no API for a repository's social preview: the image is uploaded by hand under Settings → General → Social preview. This builds those images with the site's share-card generator, so that they share its type, colors and layout and can be rebuilt from this repository rather than from a one-off script.
src/lib/og.ts: the drawing code takes the card size as a parameter (renderCard);renderOgImagedraws the site's 1200×630 cards through it as before. The GitHub cards, 1280×640 and one per site card, are defined at the end of the file.src/pages/og/github/[card].png.ts: builds them to/og/github/<card>.png. No page links to them and they are not in the sitemap./og/github/lite.png/og/github/core.png/og/github/enterprise.png/og/github/home.pngThe name and the labels are the site card's (
cardText). The line follows each repository's description on GitHub instead of the page headline, which says less about a repository: the Core page headline, for example, does not say that the repository holds crates and a binary.Verification
pnpm build(pnpm 10): the four site cards indist/og/*.pngare byte-identical to those built frommainand to the ones served by thinkwat.ch.dist/og/github/*.png: 1280×640 PNG, 91–97 KB each;sitemap-0.xmlhas no/og/URL.tsc --noEmit -p .: no errors.Once this is deployed, each image is uploaded by hand to its repository from
https://thinkwat.ch/og/github/<card>.png.🤖 Generated with Claude Code