import type { Metadata } from 'next'; import Link from 'next/link'; import { notFound } from 'next/navigation'; import { publicApi } from '@/lib/services'; import { formatDate, resolveUploadUrl } from '@/lib/utils'; import { ContentView } from '@/components/front/ContentView'; export const revalidate = 60; interface PageProps { params: { id: string }; } export async function generateMetadata({ params }: PageProps): Promise { try { const n = await publicApi.getNewsDetail(Number(params.id)); return { title: n.title, description: n.intro ?? undefined }; } catch { return { title: '新闻详情' }; } } export default async function NewsDetailPage({ params }: PageProps) { let news; try { news = await publicApi.getNewsDetail(Number(params.id)); } catch { notFound(); } return (

{news.title}

{news.category?.name && ( {news.category.name} )} 发布时间:{formatDate(news.createdAt, 'YYYY-MM-DD HH:mm')} {news.isTop === 1 && ( 置顶 )}
{news.cover && (
{/* eslint-disable-next-line @next/next/no-img-element */} {news.title}
)}
); }