Skip to content

Add share cards for every page - #10

Merged
appdever01 merged 2 commits into
opencirclehq:mainfrom
Ferousco-dev:feat/component-og-image
Nov 18, 2026
Merged

appdever01 merged 2 commits into
opencirclehq:mainfrom
Ferousco-dev:feat/component-og-image

Conversation

@Ferousco-dev

Copy link
Copy Markdown
Contributor

Link previews for OpenCircle used the same static image on every page. This PR generates a 1200×630 card for each page on the server, so a shared link shows what the page is about.

What each page shows

  • Home and /community: a podium of the current top three members with their GitHub avatars, names and points, in the style of public/og.png. If no leaderboard has been saved yet, the page keeps the static image.
  • Component pages (/components/split-footer, /components/icon-folder, /components/draw-a-line): the component name as the title, plus its description, category and tags. Long names shrink and stop at three lines with an ellipsis.
  • /repositories, /tools, /how-it-works, /blog and /components: a plain card with the page name and description.

Forum posts, blog posts and events keep the cards they already had. Private pages (admin, portfolio and similar) get none.

How it works

Three new routes draw the cards: /api/home-image, /api/page-image and /api/component-image. They reuse the satori and resvg renderer from server/forum-image.ts, which now exposes cardAssets, renderCard and cachedImage so the home card can use its own layout.

The Node server and the Vite plugin write the og:image tags into the HTML, and client-side navigation sets the same tags, including the podium on /community. Image URLs carry a short version hash, so an edited description is not served from cache. robots.txt allows the three routes.

Component names, descriptions, categories and tags moved to shared/component-meta.ts, which the registry now spreads from. The server can read them without importing the demo code.

Satori cannot fetch pictures, so the server loads avatars itself. It accepts only avatars.githubusercontent.com, with a 3 second timeout, a 512 KB cap and no redirects. If one fails, that seat shows a grey circle.

The home card reads the saved leaderboard snapshot only. A share card never waits on a GitHub refresh.

Testing

  • pnpm typecheck is clean and pnpm lint reports no errors.
  • pnpm test passes (747 tests). New tests are in tests/page-image.test.ts and tests/component-seo.test.ts. They cover every page's image tag, each component URL, long titles, bad slugs and paths, and the case with no saved leaderboard.
  • One existing assertion in tests/forum-meta.test.tsx expected /tools to use og.png. It now expects the page card.

Previews

Home and /community, /components/draw-a-line, and a very long component name:

(drag in home.png, component-draw-a-line.png and component-long-name.png)

Generate a 1200x630 Open Graph card per page on the server: a leaderboard podium for home and /community, the component name for each library page, and a plain card for the other indexed pages.
@appdever01
appdever01 merged commit 793db6d into opencirclehq:main Nov 18, 2026
@Psybah Psybah mentioned this pull request Nov 19, 2026
3 tasks done
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.

2 participants