Skip to content

link preview card for every profile - #154

Merged
iamnotstatic merged 1 commit into
mainfrom
iamnotstatic/profile-og
Nov 12, 2026
Merged

iamnotstatic merged 1 commit into
mainfrom
iamnotstatic/profile-og

Conversation

@iamnotstatic

Copy link
Copy Markdown
Owner

Pasting a profile link into X, Slack or Discord showed the generic site image. Every profile now gets its own card, so when someone shares their profile it shows their week.

What the card shows: avatar, handle, this week's rank, all-time ships with days and this month, the 12-week grid, the top crew's rank this week, and the profile URL. 1200x630, dark theme, Geist Mono.

How it works

  • GET /@handle/og.png draws the card as SVG and rasterises it in the Worker with @resvg/resvg-wasm 2.6.2 (MPL-2.0, wasm, no native code). Bundle goes to 2.9MB, 1.18MB gzipped, inside the 10MB paid limit.
  • resvg can't read woff2, so server/assets gains Geist Mono Regular and SemiBold TTFs (OFL, licence already in assets/).
  • The avatar is fetched from GitHub and embedded, since resvg can't load remote images. If that fails the card draws a plain circle.
  • Profile pages point og:image at the card with ?d=<today>, so sites that cache previews by URL pick up a fresh one daily. Other pages keep /og.png.

Keeping it from hurting the site

  • Cards are cached at the edge for 6 hours, keyed on handle and date, never the request's query string. Repeats and made-up variants of the URL (?x=a, different casing) are served from cache, so preview bots rarely reach D1.
  • Any failure, and any unknown handle, returns the existing og.png with a 200. Failures aren't cached.
  • Emoji are stripped from crew names, since the font has no emoji glyphs. A crew named only with emoji drops the crew line. One live crew ("mavericks 😎") hits this.

Checked against a local worker with seeded profiles

  • Rendered and looked at: a normal profile, a 39-character handle (handle shrinks, then truncates; URL still fits), no avatar, zero ships, an emoji crew name.
  • Unknown handle returns bytes identical to og.png. With the renderer forced to throw, the card URL also returns og.png.
  • First render 0.3 to 0.7s, cached 0.02 to 0.06s.
  • npm run typecheck --prefix server clean, npm test 228/228.

Not checked yet: the production schema (only after deploy), and how X, Slack and Discord actually display it. After deploying, paste a profile link into each, or use their card validators, and fetch a real /@handle/og.png.

Server-only, so it ships as a plain deploy with no npm release.

Pasting vibetime.club/@handle into X, Slack or Discord showed the generic
site image. Profiles now point og:image at /@handle/og.png: avatar, handle,
this week's rank, all-time ships, the 12-week grid, and the top crew's rank,
drawn as SVG and rasterised in the Worker with @resvg/resvg-wasm (no native
code, ~1.2MB gzipped). The card uses Geist Mono TTFs, since resvg can't read
the site's woff2.

Cards are cached at the edge per handle per day, keyed on the handle and the
date rather than the request's query string, so preview bots rarely reach D1
and made-up URLs can't force renders. Any failure, and any unknown handle,
answers with the existing og.png. Emoji are dropped from crew names because
the font has no emoji glyphs.
@iamnotstatic
iamnotstatic merged commit e6765ae into main Nov 12, 2026
3 checks passed
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.

1 participant