Skip to content

Commit 6adae54

Browse files
committed
feat: add nav on post meta bar
1 parent ec023c9 commit 6adae54

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

src/components/widgets/post/PostMetaBar.tsx

+44-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client'
22

3+
import Link from 'next/link'
34
import type { PostModel } from '@mx-space/api-client'
45

56
import { MdiClockOutline } from '~/components/icons/clock'
@@ -9,12 +10,17 @@ import { FloatPopover } from '~/components/ui/float-popover'
910
import { NumberSmoothTransition } from '~/components/ui/number-transition/NumberSmoothTransition'
1011
import { RelativeTime } from '~/components/ui/relative-time'
1112
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'
1217

1318
export const PostMetaBar: Component<{
1419
meta: Partial<
1520
Pick<PostModel, 'created' | 'modified' | 'category' | 'tags' | 'count'>
1621
>
1722
}> = ({ className, meta }) => {
23+
const { present } = useModalStack()
1824
return (
1925
<div
2026
className={clsxm(
@@ -46,8 +52,44 @@ export const PostMetaBar: Component<{
4652
<div className="flex min-w-0 items-center space-x-1">
4753
<FeHash className="translate-y-[0.5px]" />
4854
<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+
)}
5193
</span>
5294
</div>
5395
)}

src/components/widgets/post/fab/PostTagsFAB.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const TagInternal = memo(function TagInternal(
6969
)
7070
})
7171

72-
const TagDetailModal = (props: TagModel) => {
72+
export const TagDetailModal = (props: { name: string }) => {
7373
const { name } = props
7474
const { data, isLoading } = useQuery({
7575
queryKey: [name, 'tag'],

src/lib/fonts.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Manrope, Noto_Serif_SC } from 'next/font/google'
22

33
const sansFont = Manrope({
44
subsets: ['latin'],
5-
weight: ['400', '500'],
5+
weight: ['300', '400', '500'],
66
variable: '--font-sans',
77
display: 'swap',
88
})

0 commit comments

Comments
 (0)