1
1
'use client'
2
2
3
+ import Link from 'next/link'
3
4
import type { PostModel } from '@mx-space/api-client'
4
5
5
6
import { MdiClockOutline } from '~/components/icons/clock'
@@ -9,12 +10,17 @@ import { FloatPopover } from '~/components/ui/float-popover'
9
10
import { NumberSmoothTransition } from '~/components/ui/number-transition/NumberSmoothTransition'
10
11
import { RelativeTime } from '~/components/ui/relative-time'
11
12
import { clsxm } from '~/lib/helper'
13
+ import { routeBuilder , Routes } from '~/lib/route-builder'
14
+ import { useModalStack } from '~/providers/root/modal-stack-provider'
15
+
16
+ import { TagDetailModal } from './fab/PostTagsFAB'
12
17
13
18
export const PostMetaBar : Component < {
14
19
meta : Partial <
15
20
Pick < PostModel , 'created' | 'modified' | 'category' | 'tags' | 'count' >
16
21
>
17
22
} > = ( { className, meta } ) => {
23
+ const { present } = useModalStack ( )
18
24
return (
19
25
< div
20
26
className = { clsxm (
@@ -46,8 +52,44 @@ export const PostMetaBar: Component<{
46
52
< div className = "flex min-w-0 items-center space-x-1" >
47
53
< FeHash className = "translate-y-[0.5px]" />
48
54
< span className = "min-w-0 truncate" >
49
- { meta . category ?. name }
50
- { meta . tags ?. length ? ` / ${ meta . tags . join ( ', ' ) } ` : '' }
55
+ < Link
56
+ href = { routeBuilder ( Routes . Category , {
57
+ slug : meta . category . slug ,
58
+ } ) }
59
+ className = "shiro-link--underline font-normal"
60
+ >
61
+ { meta . category ?. name }
62
+ </ Link >
63
+
64
+ { meta . tags ?. length ? (
65
+ < >
66
+ { ' ' }
67
+ /{ ' ' }
68
+ { meta . tags . map ( ( tag , index ) => {
69
+ const isLast = index === meta . tags ! . length - 1
70
+
71
+ return (
72
+ < >
73
+ < button
74
+ className = "shiro-link--underline"
75
+ onClick = { ( ) =>
76
+ present ( {
77
+ content : ( ) => < TagDetailModal name = { tag } /> ,
78
+ title : `Tag: ${ tag } ` ,
79
+ } )
80
+ }
81
+ key = { tag }
82
+ >
83
+ { tag }
84
+ </ button >
85
+ { ! isLast && < span > , </ span > }
86
+ </ >
87
+ )
88
+ } ) }
89
+ </ >
90
+ ) : (
91
+ ''
92
+ ) }
51
93
</ span >
52
94
</ div >
53
95
) }
0 commit comments