Commit 44188432 by luoqi

Merge fully offline documentation previews into main

parents 11247484 665f8b6c
Pipeline #3775 failed in 0 seconds
......@@ -3,6 +3,7 @@ import { notFound } from 'next/navigation';
import { ImageResponse } from 'next/og';
import { generate as DefaultImage } from 'fumadocs-ui/og';
import { appName } from '@/lib/shared';
import { ogText } from '@/lib/og-text';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
......@@ -18,7 +19,7 @@ export async function GET(_req: Request, { params }: RouteContext<'/og/docs/[...
return new ImageResponse(
<div style={{ display: 'flex', width: '100%', height: '100%', fontFamily: 'PAC Docs Sans' }}>
<DefaultImage title={page.data.title} description={page.data.description} site={appName} />
<DefaultImage title={ogText(page.data.title)} description={ogText(page.data.description)} site={ogText(appName)} />
</div>,
{
width: 1200,
......
/** 分享预览用纯文本;Next/OG 会为 emoji 下载远程素材,正文保持原样。 */
export function ogText(text: string | undefined): string {
return (text ?? '').replace(/[\p{Extended_Pictographic}\p{Emoji_Presentation}\u200D\uFE0E\uFE0F\u20E3]/gu, '');
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment