11// app/layout.tsx
22import type { Metadata } from "next" ;
33import localFont from "next/font/local" ;
4- import {
5- Inter ,
6- JetBrains_Mono ,
7- Playfair_Display ,
8- Lora ,
9- } from "next/font/google" ;
104import { RootProvider } from "fumadocs-ui/provider" ;
115import Script from "next/script" ;
126import "./globals.css" ;
@@ -32,42 +26,6 @@ const geistMono = localFont({
3226 weight : "100 900" ,
3327} ) ;
3428
35- /*
36- * 四套 Google Fonts 改走 next/font/google 自托管。
37- * 收益:build 时下载到 .next/static/ 不走 Google CDN,首屏省一次第三方 CSS 往返,
38- * LCP 下降 200-500ms。自动 font-display: swap + preload + 子集化。
39- *
40- * 权重参考原来 <link> CSS URL 里的 weight/style 参数保持一致,避免 fallback 到默认 400。
41- * display: "swap" — FOUT 代替 FOIT,保证文字立刻可读(避免不可见的 UX 断层)。
42- * variable 名和 globals.css 里的 --font-* 对齐。
43- */
44- const inter = Inter ( {
45- subsets : [ "latin" ] ,
46- weight : [ "400" , "500" , "600" , "700" ] ,
47- variable : "--font-inter" ,
48- display : "swap" ,
49- } ) ;
50- const jetbrainsMono = JetBrains_Mono ( {
51- subsets : [ "latin" ] ,
52- weight : [ "400" , "500" ] ,
53- variable : "--font-jb-mono" ,
54- display : "swap" ,
55- } ) ;
56- const playfair = Playfair_Display ( {
57- subsets : [ "latin" ] ,
58- weight : [ "400" , "600" , "700" , "900" ] ,
59- style : [ "normal" , "italic" ] ,
60- variable : "--font-playfair" ,
61- display : "swap" ,
62- } ) ;
63- const lora = Lora ( {
64- subsets : [ "latin" ] ,
65- weight : [ "400" , "600" ] ,
66- style : [ "normal" , "italic" ] ,
67- variable : "--font-lora" ,
68- display : "swap" ,
69- } ) ;
70-
7129const SITE_URL =
7230 process . env . NEXT_PUBLIC_SITE_URL || "https://involutionhell.com" ;
7331const en_description =
@@ -182,10 +140,16 @@ export default async function RootLayout({
182140 return (
183141 < html lang = { htmlLang } suppressHydrationWarning >
184142 < head >
185- { /*
186- Google Fonts 的 <link> preconnect + stylesheet 已全部改走 next/font/google 自托管,
187- 不再走第三方 CDN(避免阻塞首屏 LCP、也不给 Google 收集 IP)。
188- */ }
143+ < link rel = "preconnect" href = "https://fonts.googleapis.com" />
144+ < link
145+ rel = "preconnect"
146+ href = "https://fonts.gstatic.com"
147+ crossOrigin = "anonymous"
148+ />
149+ < link
150+ rel = "stylesheet"
151+ href = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700& family = JetBrains + Mono :wght @400 ; 500 & family = Playfair + Display :ital , wght @0 , 400 ; 0 , 600 ; 0 , 700 ; 0 , 900 ; 1 , 400 & family = Lora :ital , wght @0 , 400 ; 0 , 600 ; 1 , 400 & display = swap "
152+ / >
189153 { /* 主题脚本:避免首屏闪烁 */ }
190154 < script
191155 dangerouslySetInnerHTML = { {
@@ -274,7 +238,7 @@ export default async function RootLayout({
274238 </head >
275239 < body
276240 suppressHydrationWarning
277- className = { `${ geistSans . variable } ${ geistMono . variable } ${ inter . variable } ${ jetbrainsMono . variable } ${ playfair . variable } ${ lora . variable } antialiased` }
241+ className = { `${ geistSans . variable } ${ geistMono . variable } antialiased` }
278242 >
279243 < div className = "site-bg site-bg--stars" aria - hidden / >
280244 { /*
0 commit comments