Skip to content

Commit a67bacb

Browse files
committed
Decode exported tag params at runtime
1 parent f69a730 commit a67bacb

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/app/tags/[tag]/page.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,25 @@ export const dynamicParams = false
1717

1818
export async function generateMetadata({ params }: Props): Promise<Metadata> {
1919
const { tag } = await params
20+
const decodedTag = decodeURIComponent(tag)
2021
return {
21-
title: `#${tag}`,
22-
description: `标签「${tag}」下的所有文章`,
22+
title: `#${decodedTag}`,
23+
description: `标签「${decodedTag}」下的所有文章`,
2324
}
2425
}
2526

2627
export default async function TagPage({ params }: Props) {
2728
const { tag } = await params
28-
const posts = getPostsByTag(tag)
29+
const decodedTag = decodeURIComponent(tag)
30+
const posts = getPostsByTag(decodedTag)
2931

3032
if (posts.length === 0) notFound()
3133

3234
return (
3335
<div>
3436
<div className="mb-8">
3537
<h1 className="text-sm font-mono" style={{ color: 'var(--color-fg-muted)' }}>
36-
#{tag}
38+
#{decodedTag}
3739
<span className="ml-2 opacity-50">{posts.length}</span>
3840
</h1>
3941
</div>

0 commit comments

Comments
 (0)