From a897894791fd1e372fb0a076497670c9bb7f44e5 Mon Sep 17 00:00:00 2001 From: OpenCode Worker Date: Wed, 3 Jun 2026 10:58:15 -0500 Subject: [PATCH] feat: link post tags to static tag pages --- app/posts/[slug]/page.tsx | 11 ++++++----- components/blog/PostCard.tsx | 34 +++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/app/posts/[slug]/page.tsx b/app/posts/[slug]/page.tsx index aff417a..281b9f1 100644 --- a/app/posts/[slug]/page.tsx +++ b/app/posts/[slug]/page.tsx @@ -1,5 +1,6 @@ import { notFound } from 'next/navigation' -import { getPosts, getPost } from '@/lib/posts' +import Link from 'next/link' +import { getPosts, getPost, tagToSlug } from '@/lib/posts' import { TableOfContents } from '@/components/blog/TableOfContents' import { ScrollToTop } from '@/components/ui/ScrollToTop' import { ReadingProgress } from '@/components/ui/ReadingProgress' @@ -38,7 +39,7 @@ export default async function PostPage({ params }: { params: Promise<{ slug: str
- +

{post.title}

@@ -49,7 +50,7 @@ export default async function PostPage({ params }: { params: Promise<{ slug: str {post.coverImage && ( Cover image @@ -57,9 +58,9 @@ export default async function PostPage({ params }: { params: Promise<{ slug: str {post.tags.length > 0 && (
{post.tags.map((tag) => ( - + {tag} - + ))}
)} diff --git a/components/blog/PostCard.tsx b/components/blog/PostCard.tsx index 4c15971..21eab35 100644 --- a/components/blog/PostCard.tsx +++ b/components/blog/PostCard.tsx @@ -4,6 +4,18 @@ import Link from 'next/link'; import { m } from 'motion/react'; import type { PostMeta } from '@/lib/posts'; +const tagToClientSlug = (tag: string): string => + tag + .normalize('NFKD') + .toLowerCase() + .replace(/[\u0300-\u036f]/g, '') + .replace(/\+/g, ' plus ') + .replace(/#/g, ' sharp ') + .replace(/[\\/]+/g, ' ') + .replace(/[^\p{L}\p{N}]+/gu, '-') + .replace(/-{2,}/g, '-') + .replace(/^-|-$/g, ''); + export function PostCard({ slug, title, date, excerpt, tags = [], author, readingTime, index = 0, coverImage }: PostMeta & { index?: number }) { return ( Cover image
)}
- + {author && ·} {author && {author}} {readingTime && ·} @@ -34,19 +46,19 @@ export function PostCard({ slug, title, date, excerpt, tags = [], author, readin

{title}

- {tags && tags.length > 0 && ( -
- {tags.slice(0, 3).map((tag) => ( - - {tag} - - ))} -
- )} {excerpt && (

{excerpt}

)} + {tags && tags.length > 0 && ( +
+ {tags.slice(0, 3).map((tag) => ( + + {tag} + + ))} +
+ )} ); }