Replace reverse-proxy/iframe approach with @ebook/@community/@navmini imports under /nav /book /community so localhost:3000 serves all three products directly. Co-authored-by: Cursor <cursoragent@cursor.com>
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
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(
|
|
(
|
|
<div
|
|
style={{
|
|
width: '100%',
|
|
height: '100%',
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
justifyContent: 'center',
|
|
padding: 64,
|
|
background: 'linear-gradient(155deg, #120f1d, #4c1d95 55%, #db2777)',
|
|
color: '#fff',
|
|
fontFamily: font.name,
|
|
}}
|
|
>
|
|
<div style={{ fontSize: 28, opacity: 0.7, marginBottom: 20 }}>正在阅读</div>
|
|
<div style={{ fontSize: 64, fontWeight: 700, lineHeight: 1.15 }}>{book.title}</div>
|
|
<div style={{ fontSize: 30, opacity: 0.85, marginTop: 16 }}>{book.tagline}</div>
|
|
<div style={{ fontSize: 22, opacity: 0.65, marginTop: 32 }}>
|
|
连续滚动 · {book.chapters.length} 章 · 沉浸阅读体验
|
|
</div>
|
|
</div>
|
|
),
|
|
{
|
|
...size,
|
|
fonts: [{ name: font.name, data: font.data, style: 'normal', weight: 700 }],
|
|
}
|
|
);
|
|
}
|