import { ImageResponse } from "next/og"; import type { NextRequest } from "next/server"; import { loadContent } from "@/site/load"; /** * The share image for a page without its own (ROADMAP-v3 §11: "Pages without their own image get a * share image generated from the church's logo and colours"): 1200 × 630, the church's colour, its * name and the page's title. `?t=` is the title (only shown, never trusted for anything else). */ export async function GET(request: NextRequest) { const c = await loadContent(); const title = (request.nextUrl.searchParams.get("t") ?? "").slice(0, 90); const name = c.church?.name ?? "Our church"; const rgb = (triple: string) => `rgb(${triple.split(" ").join(",")})`; const logo = c.church?.branding.logoUrl; return new ImageResponse( (
{logo && /^https:\/\//.test(logo) && !logo.endsWith(".svg") ? : null}
{name}
40 ? 64 : 80, fontWeight: 800, lineHeight: 1.1 }}>{title || name}
), { width: 1200, height: 630, headers: { "Cache-Control": "public, max-age=3600" } }, ); }