File tree 4 files changed +31
-5
lines changed
app/posts/(post-detail)/[category]/[slug]
4 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import { Markdown } from '~/components/ui/markdown'
12
12
import { PostActionAside } from '~/components/widgets/post/PostActionAside'
13
13
import { PostCopyright } from '~/components/widgets/post/PostCopyright'
14
14
import { PostMetaBar } from '~/components/widgets/post/PostMetaBar'
15
+ import { PostOutdate } from '~/components/widgets/post/PostOutdate'
15
16
import { PostRelated } from '~/components/widgets/post/PostRelated'
16
17
import { SubscribeBell } from '~/components/widgets/subscribe/SubscribeBell'
17
18
import { TocAside } from '~/components/widgets/toc'
@@ -43,6 +44,8 @@ const PostPage = () => {
43
44
< PostMetaBarInternal className = "mb-8 justify-center" />
44
45
45
46
< XLogSummaryForPost />
47
+
48
+ < PostOutdate />
46
49
</ header >
47
50
< WrappedElementProvider >
48
51
< PostMarkdownImageRecordProvider >
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ export const withNoSSR = <P,>(
7
7
) : FC < PropsWithChildren < P > > => {
8
8
return ( props : PropsWithChildren < P > ) => {
9
9
const isClient = useIsClientTransition ( )
10
- if ( ! isClient ) return props . children ?? null
10
+ if ( ! isClient ) return null
11
11
// @ts -ignore
12
12
return < Component { ...props } />
13
13
}
Original file line number Diff line number Diff line change 1
1
'use client'
2
2
3
3
import { useOnlineCount } from '~/atoms'
4
- import { withNoSSR } from '~/components/hoc/with-no-ssr'
5
4
import { FloatPopover } from '~/components/ui/float-popover'
6
5
7
- export const GatewayCount = withNoSSR ( ( ) => {
6
+ export const GatewayCount = ( ) => {
8
7
return (
9
- < FloatPopover TriggerComponent = { GatewayCountTrigger } type = "tooltip" >
8
+ < FloatPopover
9
+ as = "span"
10
+ TriggerComponent = { GatewayCountTrigger }
11
+ type = "tooltip"
12
+ >
10
13
< div className = "space-y-2 leading-relaxed" >
11
14
< p className = "flex items-center space-x-1 opacity-80" >
12
15
< i className = "icon-[mingcute--question-line]" />
@@ -23,7 +26,7 @@ export const GatewayCount = withNoSSR(() => {
23
26
</ div >
24
27
</ FloatPopover >
25
28
)
26
- } )
29
+ }
27
30
const GatewayCountTrigger = ( ) => {
28
31
const count = useOnlineCount ( )
29
32
return < span > 正在被 { count } 人看爆</ span >
Original file line number Diff line number Diff line change
1
+ import dayjs from 'dayjs'
2
+
3
+ import { Banner } from '~/components/ui/banner'
4
+ import { RelativeTime } from '~/components/ui/relative-time'
5
+ import { useCurrentPostDataSelector } from '~/providers/post/CurrentPostDataProvider'
6
+
7
+ export const PostOutdate = ( ) => {
8
+ const time = useCurrentPostDataSelector ( ( s ) => s ?. modified )
9
+ if ( ! time ) {
10
+ return null
11
+ }
12
+ return dayjs ( ) . diff ( dayjs ( time ) , 'day' ) > 60 ? (
13
+ < Banner type = "warning" className = "mb-10" >
14
+ < span className = "leading-[1.8]" >
15
+ 这篇文章上次修改于 < RelativeTime date = { time } />
16
+ ,可能部分内容已经不适用,如有疑问可询问作者。
17
+ </ span >
18
+ </ Banner >
19
+ ) : null
20
+ }
You can’t perform that action at this time.
0 commit comments