Add custom social previews for map and transparency pages#881
Merged
Conversation
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.
|
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.
Adds custom build-time OG images for
/mapand/transparencyinstead of generic MDX title cards. The map preview embeds the grantee world map and a dynamic stats sentence styled likeStatsSentence, with resvg-measured highlight pills. The transparency preview shows the three lifetime stats. Stats formatting is shared viautils/lifetimeStats.ts, sheet values are coerced to numbers, and both pages pull live stats at build time.map.pngwith world map, stats sentence, and orange highlight pillstransparency.pngwith lifetime donated, grantees, and countries funded/maptoslug="map"and fetch stats in transparencygetStaticPropsBuild preview: