@@ -4,19 +4,21 @@ import { Metadata } from 'next';
44
55import {
66 NoteTitle ,
7- NoteDateMeta ,
87 IndentArticleContainer ,
98 NoteMarkdown ,
109 PaperLayout ,
1110 PageTransition ,
1211} from './pageExtra' ;
1312
13+ import dayjs from '@/lib/dayjs' ;
14+ import { MdiClockOutline } from '@/components/icons/clock' ;
1415import { type PostItem as PostItemType , getPostData } from '@/core' ;
1516import { LayoutRightSidePortal } from '@/providers/shared/LayoutRightSideProvider' ;
1617import { ArticleRightAside } from '@/components/modules/shared/ArticleRightAside' ;
1718import { Signature } from '@/components/modules/shared/signature' ;
1819import Gisus from '@/components/modules/comment/Giscus' ;
1920import { getUserLocale } from '@/lib/getLocale' ;
21+ import localeValues from '@/locale' ;
2022
2123const { postDataMap } = await getPostData ( ) ;
2224
@@ -72,26 +74,64 @@ export default async function Page({ params }: { params: Record<string, any> })
7274 ) ;
7375}
7476
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 >
9192 </ 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