diff --git a/src/app/news/[id]/page.tsx b/src/app/news/[id]/page.tsx new file mode 100644 index 0000000..88b9242 --- /dev/null +++ b/src/app/news/[id]/page.tsx @@ -0,0 +1,132 @@ +import { notFound } from 'next/navigation'; +import { NEWS } from '@/lib/constants'; +import { Button } from '@/components/ui/button'; +import { Badge } from '@/components/ui/badge'; +import { ArrowLeft, Calendar, Share2 } from 'lucide-react'; +import Link from 'next/link'; + +export async function generateStaticParams() { + return NEWS.map((news) => ({ + id: news.id, + })); +} + +export async function generateMetadata({ params }: { params: { id: string } }) { + const news = NEWS.find((n) => n.id === params.id); + + if (!news) { + return { + title: '新闻未找到', + }; + } + + return { + title: `${news.title} - 睿新致远`, + description: news.excerpt, + }; +} + +export default function NewsDetailPage({ params }: { params: { id: string } }) { + const news = NEWS.find((n) => n.id === params.id); + + if (!news) { + notFound(); + } + + const relatedNews = NEWS + .filter((n) => n.id !== news.id && n.category === news.category) + .slice(0, 3); + + return ( +
+
+
+ + + 返回新闻列表 + +
+
+ {news.category} +
+

+ {news.title} +

+
+
+ + {news.date} +
+ +
+
+
+
+ +
+
+
+
+ 📰 +
+ +

+ {news.excerpt} +

+ +
+ {news.content} +
+
+ + {relatedNews.length > 0 && ( +
+

+ 相关新闻 +

+
+ {relatedNews.map((related) => ( + +
+
+ 📰 +
+ + {related.category} + +

+ {related.title} +

+

+ {related.excerpt} +

+
+ + ))} +
+
+ )} + +
+ + +
+
+
+
+ ); +}