File tree Expand file tree Collapse file tree 4 files changed +47
-35
lines changed
Expand file tree Collapse file tree 4 files changed +47
-35
lines changed Original file line number Diff line number Diff line change 11import Link from 'next/link' ;
22import { source } from '@/lib/source' ;
33
4- export default function HomePage ( ) {
5- const blogs = source . getPages ( ) ;
4+ // i18n文本
5+ const texts = {
6+ en : {
7+ noBlogsMessage : "No blog posts yet"
8+ } ,
9+ zh : {
10+ noBlogsMessage : "暂时还没有博客文章"
11+ }
12+ } as const ;
13+
14+ export default async function HomePage ( {
15+ params,
16+ } : {
17+ params : Promise < { lang : string } > ;
18+ } ) {
19+ const lang = ( await params ) . lang as keyof typeof texts ;
20+ // 获取指定语言的页面
21+ const blogs = source . getPages ( lang ) ;
22+ const t = texts [ lang ] || texts . en ;
623
724 return (
825 < main className = "flex flex-1 flex-col px-6 py-8" >
926 < div className = "max-w-6xl mx-auto w-full" >
1027
1128 { blogs . length === 0 ? (
1229 < p className = "text-fd-muted-foreground" >
13- 暂时还没有博客文章
30+ { t . noBlogsMessage }
1431 </ p >
1532 ) : (
1633 < div className = "grid md:grid-cols-2 gap-8 md:gap-12" >
@@ -22,7 +39,7 @@ export default function HomePage() {
2239 >
2340 < article >
2441 < h2 className = "text-2xl font-semibold text-fd-foreground" >
25- { blog . data . title || ' 无标题'}
42+ { blog . data . title || ( lang === 'zh' ? ' 无标题' : 'Untitled' ) }
2643 </ h2 >
2744
2845 { blog . data . description && (
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ const locales = [
1919 } ,
2020] ;
2121
22- export default async function RootLayout ( {
22+ export default async function Layout ( {
2323 params,
2424 children,
2525} : {
@@ -29,18 +29,14 @@ export default async function RootLayout({
2929 const lang = ( await params ) . lang ;
3030
3131 return (
32- < html lang = { lang } >
33- < body >
34- < RootProvider
35- i18n = { {
36- locale : lang ,
37- locales,
38- translations : { cn } [ lang ] ,
39- } }
40- >
41- { children }
42- </ RootProvider >
43- </ body >
44- </ html >
32+ < RootProvider
33+ i18n = { {
34+ locale : lang ,
35+ locales,
36+ translations : { cn } [ lang ] ,
37+ } }
38+ >
39+ { children }
40+ </ RootProvider >
4541 ) ;
4642}
Original file line number Diff line number Diff line change 1+ import './global.css' ;
2+ import type { ReactNode } from 'react' ;
3+
4+ export default function RootLayout ( {
5+ children,
6+ } : {
7+ children : ReactNode ;
8+ } ) {
9+ return (
10+ < html suppressHydrationWarning >
11+ < body >
12+ { children }
13+ </ body >
14+ </ html >
15+ ) ;
16+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments