import { ImageResponse } from "next/og"; import { ENGINE_URL, type Forecast } from "@/lib/api"; import { PARTIES } from "@/lib/parties"; export const runtime = "nodejs"; export const alt = "QC26 — Projection de l'élection québécoise 2026"; export const size = { width: 1200, height: 630 }; export const contentType = "image/png"; export default async function Image() { let f: Forecast | null = null; try { f = await fetch(`${ENGINE_URL}/api/forecast/latest`, { next: { revalidate: 300 } }).then((r) => r.json()); } catch { f = null; } const rows = f ? Object.entries(f.parties).filter(([id]) => id !== "aut").sort((a, b) => b[1].seatsMean - a[1].seatsMean) : []; const color = (id: string) => PARTIES.find((p) => p.id === id)?.color ?? "#999"; const date = f?.completedAt ? new Date(f.completedAt).toLocaleDateString("fr-CA", { day: "numeric", month: "long", timeZone: "America/Toronto" }) : ""; return new ImageResponse( (