Skip to content

feat: per-city Open Graph images (#122) - #138

Merged
yakew7 merged 1 commit into
StudentSuite:mainfrom
aryansk:feat/122-city-og-images
Aug 15, 2026
Merged

feat: per-city Open Graph images (#122)#138
yakew7 merged 1 commit into
StudentSuite:mainfrom
aryansk:feat/122-city-og-images

Conversation

@aryansk

@aryansk aryansk commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

What

Per-city Open Graph images, so shared city links stop unfurling as ten identical generic cards.

  • src/app/city/[slug]/opengraph-image.tsx — renders the city name, its biggest place categories with counts, and the StudyMap wordmark on the brand dark background (#0A0A0A + amber pin), at 1200×630. Mirrors the city page's generateStaticParams/dynamicParams/slug-decode so every dataset city gets an image and unknown slugs 404.
  • Fontsnext/og runs on the edge runtime with no system fonts, so the Space Grotesk typeface is fetched from Google (legacy-UA CSS request → truetype URLs, since the renderer reads ttf/otf, not woff2), cached for the process, with a graceful fallback to a system stack if the font host is unreachable — a font hiccup must never fail the build.
  • src/lib/og.ts + tests — pure, deterministic ogCitySummary() (display name, total, biggest categories first, capped at 4 with "+N more") so the card content is unit-testable.
  • Static fallback preserved — non-city routes keep the existing /brand/og.svg from the root layout (verified on / and /about).

Verification

  • next build clean; 217 distinct OG PNGs prerendered (one per city), all 1200×630 — sha256-distinct per city, mumbai renders 1,052 unique colors (real text/accents, not a flat card).
  • City pages auto-advertise their own image: /city/navi_mumbai emits <meta property="og:image" content="https://studyymap.com/city/navi_mumbai/opengraph-image">.
  • Visually confirmed the rendered card (wordmark, pin, "Mumbai / 27 student places · crowdsourced", "10 Library", "7 SAT centre" pills).
  • 56/56 vitest (4 new), eslint clean on touched files.

One note for a real unfurl test: the acceptance criteria asks for a deployed preview check via opengraph.xyz — that needs a live deploy, which this PR can't do from the fork, but the images are build-time static assets so the deployed URL will serve them at the same paths.

Every shared city link used the same generic preview. Add an
opengraph-image route to the city segment that renders the city name,
its biggest place categories, and the wordmark at 1200x630, generated at
build time for all 217 city pages. The image route mirrors the page's
static params and 404 behavior; the Space Grotesk typeface is fetched
from Google (edge runtime has no system fonts) with a cached fallback so
a font-host hiccup never fails the build. Non-city routes keep the
static /brand/og.svg card.
@yakew7
yakew7 merged commit 4e6940d into StudentSuite:main Aug 15, 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.

2 participants