import { Metadata } from "next"; import Link from "next/link"; import ReactMarkdown from "react-markdown"; import { fetchPostDetail, fetchComments } from "@/lib/api"; import CommentSection from "@/components/CommentSection"; import PostActions from "@/components/PostActions"; import LikeButton from "@/components/LikeButton"; interface PageProps { params: Promise<{ id: string }>; } export async function generateMetadata({ params }: PageProps): Promise { const { id } = await params; try { const { post } = await fetchPostDetail(id); return { title: `${post.title} - 姜十三论坛`, description: post.content.slice(0, 160), openGraph: { title: post.title, description: post.content.slice(0, 160), type: "article", }, }; } catch { return { title: "帖子不存在 - 姜十三论坛" }; } } export default async function PostDetailPage({ params }: PageProps) { const { id } = await params; const { post } = await fetchPostDetail(id); const { comments } = await fetchComments(id); const jsonLd = { "@context": "https://schema.org", "@type": "DiscussionForumPosting", headline: post.title, articleBody: post.content, datePublished: post.created_at, dateModified: post.updated_at, author: { "@type": "Person", name: post.user.nickname, }, commentCount: post.comment_count, interactionStatistic: { "@type": "InteractionCounter", interactionType: { "@type": "ReadAction" }, userInteractionCount: post.view_count, }, }; return (