@@ -4,37 +4,59 @@ import { source } from '@/lib/source';
44// i18n文本
55const texts = {
66 en : {
7- noBlogsMessage : "No blog posts yet"
7+ noBlogsMessage : "No blog posts yet" ,
8+ by : "By" ,
9+ on : "on"
810 } ,
911 'zh-Hans' : {
10- noBlogsMessage : "暂时还没有博客文章"
12+ noBlogsMessage : "暂时还没有博客文章" ,
13+ by : "作者" ,
14+ on : "发布于"
1115 } ,
1216 'zh-Hant' : {
13- noBlogsMessage : "暫時還沒有部落格文章"
17+ noBlogsMessage : "暫時還沒有部落格文章" ,
18+ by : "作者" ,
19+ on : "發布於"
1420 } ,
1521 ja : {
16- noBlogsMessage : "まだブログ記事がありません"
22+ noBlogsMessage : "まだブログ記事がありません" ,
23+ by : "著者" ,
24+ on : "投稿日"
1725 } ,
1826 fr : {
19- noBlogsMessage : "Aucun article de blog pour le moment"
27+ noBlogsMessage : "Aucun article de blog pour le moment" ,
28+ by : "Par" ,
29+ on : "le"
2030 } ,
2131 es : {
22- noBlogsMessage : "Aún no hay publicaciones en el blog"
32+ noBlogsMessage : "Aún no hay publicaciones en el blog" ,
33+ by : "Por" ,
34+ on : "el"
2335 } ,
2436 pt : {
25- noBlogsMessage : "Ainda não há postagens no blog"
37+ noBlogsMessage : "Ainda não há postagens no blog" ,
38+ by : "Por" ,
39+ on : "em"
2640 } ,
2741 ko : {
28- noBlogsMessage : "아직 블로그 글이 없습니다"
42+ noBlogsMessage : "아직 블로그 글이 없습니다" ,
43+ by : "작성자" ,
44+ on : "작성일"
2945 } ,
3046 ms : {
31- noBlogsMessage : "Belum ada catatan blog lagi"
47+ noBlogsMessage : "Belum ada catatan blog lagi" ,
48+ by : "Oleh" ,
49+ on : "pada"
3250 } ,
3351 id : {
34- noBlogsMessage : "Belum ada postingan blog"
52+ noBlogsMessage : "Belum ada postingan blog" ,
53+ by : "Oleh" ,
54+ on : "pada"
3555 } ,
3656 ru : {
37- noBlogsMessage : "Пока нет записей в блоге"
57+ noBlogsMessage : "Пока нет записей в блоге" ,
58+ by : "Автор" ,
59+ on : "опубликовано"
3860 }
3961} as const ;
4062
@@ -45,7 +67,23 @@ export default async function HomePage({
4567} ) {
4668 const lang = ( await params ) . lang as keyof typeof texts ;
4769 // 获取指定语言的页面
48- const blogs = source . getPages ( lang ) ;
70+ const allBlogs = source . getPages ( lang ) ;
71+
72+ // 按日期排序,新的在前(降序)
73+ const blogs = allBlogs . sort ( ( a , b ) => {
74+ const dateA = a . data . date ;
75+ const dateB = b . data . date ;
76+
77+ // 如果两个都没有日期,保持原有顺序
78+ if ( ! dateA && ! dateB ) return 0 ;
79+ // 没有日期的放在后面
80+ if ( ! dateA ) return 1 ;
81+ if ( ! dateB ) return - 1 ;
82+
83+ // 按日期降序排列(新的在前)
84+ return dateB . getTime ( ) - dateA . getTime ( ) ;
85+ } ) ;
86+
4987 const t = texts [ lang ] || texts . en ;
5088
5189 return (
@@ -62,18 +100,53 @@ export default async function HomePage({
62100 < Link
63101 key = { blog . url }
64102 href = { blog . url }
65- className = "block space-y-3 pb-8"
103+ className = "block space-y-3 pb-8 border-b border-fd-border last:border-b-0 "
66104 >
67- < article >
68- < h2 className = "text-2xl font-semibold text-fd-foreground" >
105+ < article className = "space-y-3" >
106+ < h2 className = "text-2xl font-semibold text-fd-foreground hover:text-fd-primary transition-colors " >
69107 { blog . data . title || ( lang === 'zh-Hans' ? '无标题' : 'Untitled' ) }
70108 </ h2 >
71109
110+ { /* 作者和日期信息 */ }
111+ { ( blog . data . author || blog . data . date ) && (
112+ < div className = "flex items-center gap-4 text-sm text-fd-muted-foreground" >
113+ { blog . data . author && (
114+ < span className = "flex items-center gap-1" >
115+ { t . by } { blog . data . author }
116+ </ span >
117+ ) }
118+ { blog . data . date && (
119+ < span className = "flex items-center gap-1" >
120+ { t . on } { blog . data . date . toLocaleDateString ( ) }
121+ </ span >
122+ ) }
123+ </ div >
124+ ) }
125+
72126 { blog . data . description && (
73127 < p className = "text-fd-muted-foreground leading-relaxed" >
74128 { blog . data . description }
75129 </ p >
76130 ) }
131+
132+ { /* 关键词标签 */ }
133+ { blog . data . keywords && (
134+ < div className = "flex flex-wrap gap-2 mt-3" >
135+ { blog . data . keywords . split ( ',' ) . slice ( 0 , 5 ) . map ( ( keyword , index ) => (
136+ < span
137+ key = { index }
138+ className = "px-2 py-1 bg-fd-secondary text-fd-secondary-foreground text-xs rounded-md"
139+ >
140+ { keyword . trim ( ) }
141+ </ span >
142+ ) ) }
143+ { blog . data . keywords . split ( ',' ) . length > 5 && (
144+ < span className = "px-2 py-1 text-fd-muted-foreground text-xs" >
145+ +{ blog . data . keywords . split ( ',' ) . length - 5 }
146+ </ span >
147+ ) }
148+ </ div >
149+ ) }
77150 </ article >
78151 </ Link >
79152 ) ) }
0 commit comments