import { ImageResponse } from 'next/og'; import { getBook } from '@ebook/lib/book.server'; export const runtime = 'nodejs'; export const dynamic = 'force-dynamic'; export const alt = 'Read ebook'; export const size = { width: 1200, height: 630 }; export const contentType = 'image/png'; async function loadFont() { const res = await fetch( 'https://fonts.gstatic.com/s/inter/v13/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuFuYAZ9hiJ-Ek-_EeA.woff2' ); return { data: await res.arrayBuffer(), name: 'Inter' }; } export default async function ReadOgImage() { const book = getBook(); const font = await loadFont(); return new ImageResponse( (
正在阅读
{book.title}
{book.tagline}
连续滚动 · {book.chapters.length} 章 · 沉浸阅读体验
), { ...size, fonts: [{ name: font.name, data: font.data, style: 'normal', weight: 700 }], } ); }