Skip to content

Add custom social previews for map and transparency pages#881

Merged
dergigi merged 13 commits into
masterfrom
map-social-preview
Jun 26, 2026
Merged

Add custom social previews for map and transparency pages#881
dergigi merged 13 commits into
masterfrom
map-social-preview

Conversation

@dergigi

@dergigi dergigi commented Jun 26, 2026

Copy link
Copy Markdown
Member

Adds custom build-time OG images for /map and /transparency instead of generic MDX title cards. The map preview embeds the grantee world map and a dynamic stats sentence styled like StatsSentence, with resvg-measured highlight pills. The transparency preview shows the three lifetime stats. Stats formatting is shared via utils/lifetimeStats.ts, sheet values are coerced to numbers, and both pages pull live stats at build time.

  • Generate map.png with world map, stats sentence, and orange highlight pills
  • Generate transparency.png with lifetime donated, grantees, and countries funded
  • Wire /map to slug="map" and fetch stats in transparency getStaticProps

Build preview:

dergigi added 12 commits June 26, 2026 12:08
Extract formatLifetimeStatDisplay and export normalizeLifetimeStats so
the transparency page and OG generator can render the same stat labels.
Point /map meta tags at pages/og/map.png instead of the default brand card.
Generate map.png via EXTRA_PAGES and a custom transparency card that
shows the three lifetime stats at build time, importing shared formatting
from utils/lifetimeStats.ts via esbuild-register.
Parse string values from Google Sheets instead of silently falling back,
update DEFAULT_LIFETIME_STATS to match current numbers, and add
resolveLifetimeStats for build-time callers.
Pass initialStats into LifetimeStats via getStaticProps with 12h ISR,
and use resolveLifetimeStats in the OG generator so the page and social
preview share the same build-time numbers.
Extract shared grantee map rendering into scripts/lib/grantee-map.mjs and
use it for a map-specific OG layout with orange highlighted countries.
Share stats formatting with StatsSentence via formatStatsSentenceValues
and formatMapOgSentence so map.png uses live grantee and sats counts at
generation time.
Drop the Map headline and render highlighted stat pills with orange-100
backgrounds, sharing segment data via formatMapOgSentenceSegments.
Improve text measurement, merge plain runs for natural word spacing,
glue connectors to stat pills, and bump type size to 38px.
Measure highlight widths via resvg getBBox, keep connector words atomic
when wrapping, and add a small gap so pills do not overlap plain text.
Anchor pills on the measured ink bounding box so left and right padding
stay equal regardless of the glyph left side bearing.
@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
os-website Ready Ready Preview, Comment Jun 26, 2026 2:30pm

Request Review

@dergigi dergigi merged commit ee1d316 into master Jun 26, 2026
3 checks passed
@dergigi dergigi deleted the map-social-preview branch June 26, 2026 14:32
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