import Link from 'next/link' import { notFound } from 'next/navigation' import type { Metadata } from 'next' import { ArrowLeft } from 'lucide-react' import type { Article } from '@homaroma/types' import { API_BASE } from '../../../lib/api' async function getArticle(slug: string): Promise
{ try { const res = await fetch(`${API_BASE}/articles/${slug}`, { next: { revalidate: 300 } }) return res.ok ? res.json() : null } catch { return null } } export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise { const { slug } = await params const article = await getArticle(slug) if (!article) return { title: 'Article Not Found | HomAroma' } return { title: `${article.title} | HomAroma Scent Guide`, description: article.content.replace(/<[^>]+>/g, '').slice(0, 160), openGraph: { title: article.title, images: article.coverImage ? [article.coverImage] : [], type: 'article', publishedTime: article.createdAt, }, } } export default async function ArticleReaderPage({ params }: { params: Promise<{ slug: string }> }) { const { slug } = await params const article = await getArticle(slug) if (!article) notFound() return (
{/* Desktop back button */} {/* Header */}
Go Back

{new Date(article.createdAt).toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' })}

{article.title}

{/* Cover Image */} {article.coverImage && (
{article.title}
)} {/* Content Body */}
) }