feat: 添加霞鹜文楷字体到文章主标题

- 使用 Google Fonts 的 LXGW WenKai TC 字体
- 仅应用到文章主标题 (.prose h1 和 .type-display)
- 只加载 Regular (400) 和 Bold (700) 字重以优化性能
- 添加字体子集化脚本(可选,用于本地字体文件)
- 保持系统字体作为 fallback

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-13 15:05:00 +08:00
parent ed63ec7d9a
commit 2229f6bb6f
3 changed files with 79 additions and 5 deletions

View File

@@ -3,7 +3,7 @@ import type { Metadata } from 'next';
import { siteConfig } from '@/lib/config';
import { LayoutShell } from '@/components/layout-shell';
import { ThemeProvider } from 'next-themes';
import { Playfair_Display } from 'next/font/google';
import { Playfair_Display, LXGW_WenKai_TC } from 'next/font/google';
import { JsonLd } from '@/components/json-ld';
const playfair = Playfair_Display({
@@ -12,6 +12,14 @@ const playfair = Playfair_Display({
display: 'swap',
});
const lxgwWenKai = LXGW_WenKai_TC({
weight: ['400', '700'], // 只加载 Regular 和 Bold
subsets: ['latin'],
variable: '--font-serif-cn',
display: 'swap',
preload: true,
});
export const metadata: Metadata = {
title: {
default: siteConfig.title,
@@ -88,7 +96,7 @@ export default function RootLayout({
};
return (
<html lang={siteConfig.defaultLocale} suppressHydrationWarning className={playfair.variable}>
<html lang={siteConfig.defaultLocale} suppressHydrationWarning className={`${playfair.variable} ${lxgwWenKai.variable}`}>
<body>
<JsonLd data={websiteSchema} />
<JsonLd data={organizationSchema} />