Link tags to tag pages and add tag overview

This commit is contained in:
2025-11-17 18:40:27 +08:00
parent 3253e70a37
commit 7c5962485c
4 changed files with 62 additions and 9 deletions

View File

@@ -1,3 +1,4 @@
import Link from 'next/link';
import { notFound } from 'next/navigation';
import type { Metadata } from 'next';
import { allPosts } from 'contentlayer/generated';
@@ -55,12 +56,13 @@ export default function BlogPostPage({ params }: Props) {
{post.tags && (
<div className="flex flex-wrap gap-2 pt-1">
{post.tags.map((t) => (
<span
<Link
key={t}
className="rounded-full bg-slate-100 px-2 py-0.5 text-xs text-slate-700 dark:bg-slate-800 dark:text-slate-300"
href={`/tags/${encodeURIComponent(t)}`}
className="rounded-full bg-slate-100 px-2 py-0.5 text-xs text-slate-700 hover:bg-slate-200 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700"
>
#{t}
</span>
</Link>
))}
</div>
)}