fix(og): PNG fallback for non-city routes and robust font-weight parsing - #139
Merged
Conversation
- layout.tsx: switch default OG image from og.svg to og.png. SVG og:image is rejected by Facebook, X, WhatsApp, iMessage — never unfurls outside the site. The existing og.png (924x540) becomes the fallback; a proper 1200x630 export can follow. - city-pages.ts: add findCityPage() to centralize slug decoding and lookup, removing duplicated decodeSlug logic from the city page and its OG image route. - opengraph-image.tsx: parse font-weight from each @font-face block instead of assuming array index [0]=400, [1]=700. Now weight is explicit per font; misordered/changed Google CSS can no longer silently swap weights. Also dedupes multiple blocks per weight. Closes #122 follow-ups from review of #138.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Follow-up fixes from reviewing the #122 implementation (PR #138):
Changes
Root OG fallback → PNG (
src/app/layout.tsx:25)og:imageis rejected by Facebook, X, WhatsApp, iMessage — never unfurls outside the site./brand/og.png(924×540). A proper 1200×630 export can follow in a separate PR.Centralized city lookup (
src/lib/city-pages.ts,src/app/city/[slug]/page.tsx,src/app/city/[slug]/opengraph-image.tsx)findCityPage(places, rawSlug)helper handles percent-decoding + dataset lookup.decodeSlug+cityPages().find()in both the city page and its OG image route.Robust font-weight loading (
src/app/city/[slug]/opengraph-image.tsx:39-71)font-weight:from each@font-faceblock, carries weight with the font data, and dedupes by weight.Verification
ogCitySummarytests)next buildsucceeds: 217 distinct per-city 1200×630 PNGs prerendered/aboutnow emitsog:image = /brand/og.png; city pages emit their own imageNote on fallback dimensions
The existing
public/brand/og.pngis 924×540 (1.71:1) vs the OG standard 1200×630 (1.91:1). Facebook/X accept it but may crop slightly. A follow-up to regenerate at 1200×630 with brand fonts embedded would be ideal; this PR uses what's available to unblock unfurls today.Closes the outstanding follow-ups from the review of #138 (which closed #122).