HTML 77.2%
TypeScript 10.5%
Python 9.6%
JavaScript 2.5%
1import { ImageResponse } from 'next/og';2import type { NextRequest } from 'next/server';3import { Wallpaper } from '@/components/brand/og';4import { daysBefore, ISO_DAY, todayUtc } from '@/components/temporal/dates';5import { apiD3, safe } from '@/lib/api';6import { fmtDate, fmtInt, num } from '@/lib/format';78export const runtime = 'nodejs';9export const revalidate = 1800;1011/** Dynamic OG image for /diff?a=&b=&scope= — both dates and the live counts. */12export async function GET(req: NextRequest): Promise<Response> {13 const sp = req.nextUrl.searchParams;14 const b = ISO_DAY.test(sp.get('b') ?? '') ? (sp.get('b') as string) : todayUtc();15 const a = ISO_DAY.test(sp.get('a') ?? '') ? (sp.get('a') as string) : daysBefore(b, 7);16 const scope = sp.get('scope') || 'all';17 const d = a < b ? await safe(apiD3.diff(a, b, scope, 1)) : null;18 const c = d?.counts ?? {};19 const n = (k: string) => fmtInt(num(c[k]));20 const counters: [string, string][] = d ? [['New entities', n('new_entities')], ['Price changes', n('price_changes')], ['Context', n('context_changes')], ['New leaders', n('new_benchmark_leaders')], ['Events', n('events')]] : [];21 return new ImageResponse(<Wallpaper eyebrow={`Diff the AI world${scope !== 'all' ? ` · ${scope}` : ''}`} title={`${fmtDate(a)} → ${fmtDate(b)}`} subtitle="New and retired models, price and context changes, new benchmark leaders, papers, providers, hardware — from the change log, nothing inferred." counters={counters} footer={`www.ai-atlas.co/diff?a=${a}&b=${b}`} markPx={200} />, { width: 1200, height: 630 });22}23