import { ImageResponse } from "next/og" import { OG_CONTENT_TYPE, OG_SIZE, ellipsize, resolveBrandLogoUrl } from "@/app/api/og/_shared" import { getDeveloperSummaryById } from "@/lib/data-backend" import { routeIdFromSegments } from "@/lib/utils" export const runtime = "nodejs" /** * Dynamic OpenGraph image for a developer page. Pulls the developer's * model + evaluation counts out of the same summary the page uses so the * unfurl identifies the specific developer rather than rendering the * generic site card. Co-located under /api/og/ rather than as an * `opengraph-image.tsx` sibling of the page because Next.js 15 rejects * metadata files inside catch-all (`[...id]`) folders. */ export async function GET( request: Request, context: { params: Promise<{ id: string | string[] }> }, ) { const { id } = await context.params const routeId = routeIdFromSegments(id) let developerName = "Developer" let modelCount: number | null = null let evaluationCount: number | null = null try { const summary = await getDeveloperSummaryById(routeId) if (summary) { developerName = summary.developer ?? developerName modelCount = summary.model_count ?? summary.models?.length ?? null evaluationCount = summary.evaluation_count ?? null } } catch { // Fall through to the generic card. } const logoUrl = resolveBrandLogoUrl(request) const displayName = ellipsize(developerName, 64) const response = new ImageResponse( (