import { ImageResponse } from 'next/og'; import type { NextRequest } from 'next/server'; import { Wallpaper } from '@/components/brand/og'; import { todayUtc, validDay } from '@/components/temporal/dates'; import { apiD3, safe } from '@/lib/api'; import { fmtDate, fmtInt } from '@/lib/format'; export const runtime = 'nodejs'; export const revalidate = 3600; /** Dynamic OG image for /time-machine?date= — the date and the live as-of counters. */ export async function GET(req: NextRequest): Promise { const sp = req.nextUrl.searchParams; const date = validDay(sp.get('date')) ?? todayUtc(); const tm = await safe(apiD3.timeMachine(date, 'all', 1)); const counters: [string, string][] = tm ? [['Models', fmtInt(tm.models?.total)], ['Offers valid', fmtInt(tm.prices?.total)], ['Leaders', fmtInt(tm.benchmarks?.leaders?.length)], ['Basis', tm.reconstructed ? 'reconstructed' : 'observed']] : []; return new ImageResponse(, { width: 1200, height: 630 }); }