diff --git a/app/blog/[slug]/page.tsx b/app/blog/[slug]/page.tsx
index beb1d9c..d815752 100644
--- a/app/blog/[slug]/page.tsx
+++ b/app/blog/[slug]/page.tsx
@@ -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 && (
{post.tags.map((t) => (
-
#{t}
-
+
))}
)}
diff --git a/app/tags/[tag]/page.tsx b/app/tags/[tag]/page.tsx
new file mode 100644
index 0000000..cccbc5b
--- /dev/null
+++ b/app/tags/[tag]/page.tsx
@@ -0,0 +1,49 @@
+import type { Metadata } from 'next';
+import { allPosts } from 'contentlayer/generated';
+import { PostListItem } from '@/components/post-list-item';
+
+export function generateStaticParams() {
+ const tags = new Set();
+ for (const post of allPosts) {
+ if (!post.tags) continue;
+ for (const tag of post.tags) {
+ tags.add(tag);
+ }
+ }
+ return Array.from(tags).map((tag) => ({
+ tag
+ }));
+}
+
+interface Props {
+ params: { tag: string };
+}
+
+export function generateMetadata({ params }: Props): Metadata {
+ const tag = params.tag;
+ return {
+ title: `標籤:${tag}`
+ };
+}
+
+export default function TagPage({ params }: Props) {
+ const tag = params.tag;
+
+ const posts = allPosts.filter(
+ (post) => post.tags && post.tags.includes(tag)
+ );
+
+ return (
+
+
+ 標籤:{tag}
+
+
+ {posts.map((post) => (
+
+ ))}
+
+
+ );
+}
+
diff --git a/components/post-list-item.tsx b/components/post-list-item.tsx
index e3e7826..937804f 100644
--- a/components/post-list-item.tsx
+++ b/components/post-list-item.tsx
@@ -43,12 +43,13 @@ export function PostListItem({ post }: Props) {
{post.tags && post.tags.length > 0 && (
{post.tags.slice(0, 4).map((t) => (
-
#{t}
-
+
))}
)}
diff --git a/components/right-sidebar.tsx b/components/right-sidebar.tsx
index a2648af..71a1f4d 100644
--- a/components/right-sidebar.tsx
+++ b/components/right-sidebar.tsx
@@ -47,12 +47,13 @@ export function RightSidebar() {
else if (count >= 3) sizeClass = 'text-xs font-medium';
return (
-
{tag}
-
+
);
})}