import type { Metadata } from "next"; import Link from "next/link"; import { cookies } from "next/headers"; 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"; import ReadingProgress from "@/components/ReadingProgress"; import Avatar from "@/components/Avatar"; import { IconComment, IconEye } from "@/components/Icons"; import { ChevronRight } from "lucide-react"; 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 cookie = (await cookies()).toString(); const { post } = await fetchPostDetail(id, cookie); 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 (