import { ImageResponse } from 'next/og'; import { getBook } from '@ebook/lib/book.server'; export const runtime = 'nodejs'; export const dynamic = 'force-dynamic'; export const alt = 'Ebook cover'; export const size = { width: 1200, height: 630 }; export const contentType = 'image/png'; async function loadFont() { const urls = [ 'https://cdn.jsdelivr.net/fontsource/fonts/noto-sans-sc@5.0.0/chinese-simplified-700-normal.woff', 'https://fonts.gstatic.com/s/inter/v13/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuFuYAZ9hiJ-Ek-_EeA.woff2', ]; for (const url of urls) { try { const res = await fetch(url, { cache: 'force-cache' }); if (res.ok) return { data: await res.arrayBuffer(), name: url.includes('noto') ? 'Noto Sans SC' : 'Inter' }; } catch { /* try next */ } } const inter = await fetch( 'https://fonts.gstatic.com/s/inter/v13/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuFuYAZ9hiJ-Ek-_EeA.woff2' ); return { data: await inter.arrayBuffer(), name: 'Inter' }; } export default async function OgImage() { const book = getBook(); const font = await loadFont(); return new ImageResponse( (