@@ -4,19 +4,21 @@ import { Metadata } from 'next';
4
4
5
5
import {
6
6
NoteTitle ,
7
- NoteDateMeta ,
8
7
IndentArticleContainer ,
9
8
NoteMarkdown ,
10
9
PaperLayout ,
11
10
PageTransition ,
12
11
} from './pageExtra' ;
13
12
13
+ import dayjs from '@/lib/dayjs' ;
14
+ import { MdiClockOutline } from '@/components/icons/clock' ;
14
15
import { type PostItem as PostItemType , getPostData } from '@/core' ;
15
16
import { LayoutRightSidePortal } from '@/providers/shared/LayoutRightSideProvider' ;
16
17
import { ArticleRightAside } from '@/components/modules/shared/ArticleRightAside' ;
17
18
import { Signature } from '@/components/modules/shared/signature' ;
18
19
import Gisus from '@/components/modules/comment/Giscus' ;
19
20
import { getUserLocale } from '@/lib/getLocale' ;
21
+ import localeValues from '@/locale' ;
20
22
21
23
const { postDataMap } = await getPostData ( ) ;
22
24
@@ -72,26 +74,64 @@ export default async function Page({ params }: { params: Record<string, any> })
72
74
) ;
73
75
}
74
76
75
- const PageInner = ( { postData } : PageInnerProps ) => (
76
- < >
77
- < div >
78
- < NoteTitle title = { postData . title } />
79
- < span className = "flex flex-wrap items-center text-sm text-neutral-content/60" >
80
- < NoteDateMeta
81
- createdAt = { postData . createdAt ! }
82
- updatedAt = { postData . updatedAt ! }
83
- modified = { postData . modified }
84
- />
85
- </ span >
86
- </ div >
87
- < IndentArticleContainer >
88
- < NoteMarkdown text = { postData . text } />
89
- < div className = "signature-animated my-2 flex w-full justify-end" data-hide-print = "true" >
90
- < Signature />
77
+ const PageInner = ( { postData } : PageInnerProps ) => {
78
+ const lang = getUserLocale ( ) ;
79
+ const notesLocale = localeValues [ lang ] . notes ;
80
+
81
+ return (
82
+ < >
83
+ < div >
84
+ < NoteTitle title = { postData . title } />
85
+ < span className = "flex flex-wrap items-center text-sm text-neutral-content/60" >
86
+ < NoteDateMeta
87
+ createdAt = { postData . createdAt ! }
88
+ updatedAt = { postData . updatedAt ! }
89
+ modified = { postData . modified }
90
+ />
91
+ </ span >
91
92
</ div >
92
- < LayoutRightSidePortal >
93
- < ArticleRightAside > </ ArticleRightAside >
94
- </ LayoutRightSidePortal >
95
- </ IndentArticleContainer >
96
- </ >
97
- ) ;
93
+ < IndentArticleContainer >
94
+ < NoteMarkdown text = { postData . text } />
95
+ < div className = "signature-animated my-2 flex w-full justify-end" data-hide-print = "true" >
96
+ < Signature />
97
+ </ div >
98
+ < LayoutRightSidePortal >
99
+ < ArticleRightAside locale = { notesLocale } />
100
+ </ LayoutRightSidePortal >
101
+ </ IndentArticleContainer >
102
+ </ >
103
+ ) ;
104
+ } ;
105
+
106
+ const NoteDateMeta = ( {
107
+ createdAt,
108
+ updatedAt,
109
+ modified,
110
+ } : {
111
+ createdAt : Date ;
112
+ updatedAt : Date ;
113
+ modified : boolean ;
114
+ } ) => {
115
+ const lang = getUserLocale ( ) ;
116
+ const notesLocale = localeValues [ lang ] . notes ;
117
+
118
+ const isZh = lang === 'zh' ;
119
+ const formatDate = ( date : Date ) =>
120
+ isZh
121
+ ? dayjs ( date ) . format ( 'YYYY 年 M 月 D 日' )
122
+ : dayjs ( date ) . locale ( 'en' ) . format ( 'MMMM D, YYYY' ) ;
123
+
124
+ return (
125
+ < span className = "inline-flex items-center space-x-1" >
126
+ < MdiClockOutline />
127
+ < time className = "font-semibold text-sm font-mono" >
128
+ { formatDate ( createdAt ) }
129
+ { modified && (
130
+ < >
131
+ { notesLocale [ 'Updated on' ] } { formatDate ( updatedAt ) }
132
+ </ >
133
+ ) }
134
+ </ time >
135
+ </ span >
136
+ ) ;
137
+ } ;
0 commit comments