import type { Metadata } from "next" import Image from "next/image" import Link from "next/link" import { notFound } from "next/navigation" import { BLOG_POSTS } from "@/lib/blog-data" interface Props { params: Promise<{ slug: string }> } export async function generateStaticParams() { return BLOG_POSTS.map((post) => ({ slug: post.slug })) } export async function generateMetadata({ params }: Props): Promise { const { slug } = await params const post = BLOG_POSTS.find((p) => p.slug === slug) if (!post) return { title: "文章未找到" } return { title: `${post.title} | DAL Code`, description: post.excerpt, openGraph: { title: `${post.title} | DAL Code`, description: post.excerpt, images: [{ url: post.image }], }, } } export default async function BlogPostPage({ params }: Props) { const { slug } = await params const post = BLOG_POSTS.find((p) => p.slug === slug) if (!post) notFound() return (
{post.date}
·
{post.category}

{post.title}

{post.excerpt}

{post.imageAlt}
{post.sections.map((section) => (

{section.title}

{section.paragraphs.map((paragraph) => (

{paragraph}

))}
))}
返回全部文章
) }