OG Image Fallback
The app generates a branded Open Graph image automatically when a Contentstack entry has no metadata.image.
Endpoint
/api/og?title={title}&type={type}&path={path}
The endpoint uses Next.js ImageResponse (next/og) and returns a 1200x630 image suitable for social sharing.
Metadata Integration
lib/contentstack/metadata.ts now resolves OG images like this:
- Use CMS image (
metadata.image.url) when available. - If missing, build a fallback URL to
/api/ogwith:title: entry titletype: normalized content type label (Blog Post, Guide, Live Stream, etc.)path: entry URL path
Card Integration
List cards and typeahead/search cards also use the OG generator as a fallback when entry/card images are missing.
- Linked cards (
linked_cards) fall back frommetadata.imageto generated/api/og. - Static cards (
cards) fall back from uploadedimageandimage_urlto generated/api/og. - Search suggestions include generated
/api/ogimages whenmetadata.imageis absent.
Behavior Notes
- Fallback OG image URLs are absolute and use
getBaseUrl()fromlib/contentstack/sitemap.ts. - The renderer uses a unified teal-focused visual style across all fallback OG images.
- The OG header combines
app/favicon.svgandpublic/Developers_Dark.svg. - The header no longer renders a top-right content-type badge.
- The title and path are grouped at the bottom; longer titles grow upward above the path row.
- It attempts to use local Beausite brand fonts and safely falls back to system fonts if unavailable.
- The generator clamps input length for stable rendering and safe layout.
- Existing CMS-defined OG images always take precedence.