feat: link post tags to static tag pages

This commit is contained in:
OpenCode Worker
2026-06-03 10:58:15 -05:00
parent 381e6225e1
commit a897894791
2 changed files with 29 additions and 16 deletions

View File

@@ -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
<div className="grid grid-cols-1 lg:grid-cols-[1fr_200px] gap-8">
<article>
<header className="mb-12">
<time className="font-mono text-sm text-ink-soft">{new Date(post.date).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' })}</time>
<time className="font-mono text-sm text-ink-soft" dateTime={post.date}>{new Date(post.date).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' })}</time>
<h1 className="heading-xl text-ink mt-3 mb-2">
{post.title}
</h1>
@@ -49,7 +50,7 @@ export default async function PostPage({ params }: { params: Promise<{ slug: str
{post.coverImage && (
<img
src={post.coverImage}
alt="Cover image"
alt={`Cover image for ${post.title}`}
className="w-full h-64 object-cover rounded-xl my-6"
loading="lazy"
/>
@@ -57,9 +58,9 @@ export default async function PostPage({ params }: { params: Promise<{ slug: str
{post.tags.length > 0 && (
<div className="flex flex-wrap gap-2 mt-4">
{post.tags.map((tag) => (
<span key={tag} className="rounded-full bg-surface px-3 py-1 text-xs font-medium text-ink-soft border border-border">
<Link key={tag} href={`/tags/${tagToSlug(tag)}/`} className="rounded-full bg-surface px-3 py-1 text-xs font-medium text-ink-soft border border-border transition-colors hover:border-accent/50 hover:text-accent focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent">
{tag}
</span>
</Link>
))}
</div>
)}