import { ImageResponse } from 'next/og'; import { fmt, fmtDelta } from '@/lib/format'; import { levelById, pressureColor } from '@/lib/pressure'; import { TAGLINE } from '@/lib/site'; import type { GlobalPressure } from '@/lib/types'; export const runtime = 'nodejs'; export const dynamic = 'force-dynamic'; export const alt = 'Global Internet Pressure right now'; export const size = { width: 1200, height: 630 }; export const contentType = 'image/png'; /** OG image rendered from the live index (real API data, never a fixture). Falls back to an unknown state. */ /** The brand dial (same geometry as scripts/brand.py / public/brand/mark.svg). */ function Dial({ SZ, OP }: { SZ: number; OP: number }) { return ( ); } export default async function OpenGraphImage() { let g: GlobalPressure | null = null; try { const res = await fetch((process.env.API_URL_INTERNAL ?? process.env.API_URL ?? 'http://127.0.0.1:8352') + '/api/v1/pressure/global', { cache: 'no-store' }); if (res.ok) g = (await res.json()) as GlobalPressure; } catch { g = null; } const color = g ? pressureColor(g.level) : '#8B98A5'; const degraded = !g || g.internal_status !== 'ok' || g.stale; return new ImageResponse( (
InternetPressure.io
GLOBAL INTERNET PRESSURE
{g ? fmt(g.pressure) : '—'}
{g ? (levelById(g.level)?.short ?? g.level).toUpperCase() : 'UNAVAILABLE'}
{g &&
{`${g.trend === 'rising' ? '↑' : g.trend === 'falling' ? '↓' : '→'} ${fmtDelta(g.delta_1h)} / 1h`}
} {degraded &&
Instrument degraded — score frozen
}
{TAGLINE}
{g &&
{`${g.coverage.probes_active} probes · ${g.coverage.probe_regions} regions · ${g.coverage.targets} targets · confidence ${Math.round(g.confidence * 100)} %`}
}
), { ...size }, ); }