feat: 添加面包屑导航组件并优化页面布局
refactor: 重构页面结构和导航逻辑 fix: 修复移动端菜单导航和滚动行为 perf: 优化图片加载性能和资源请求 test: 添加端到端测试和性能测试用例 docs: 更新.gitignore文件 chore: 更新依赖和配置 style: 优化代码格式和类型安全 ci: 调整Playwright测试超时时间 build: 更新Next.js配置和构建选项
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { notFound } from 'next/navigation';
|
||||
import { NEWS } from '@/lib/constants';
|
||||
import { NewsDetailClient } from './NewsDetailClient';
|
||||
|
||||
export async function generateStaticParams() {
|
||||
return NEWS.map((news) => ({
|
||||
slug: news.id,
|
||||
}));
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }) {
|
||||
const { slug } = await params;
|
||||
const news = NEWS.find((n) => n.id === slug);
|
||||
|
||||
if (!news) {
|
||||
return {
|
||||
title: '新闻未找到',
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
title: `${news.title} - 睿新致远`,
|
||||
description: news.excerpt,
|
||||
};
|
||||
}
|
||||
|
||||
export default async function NewsDetailPage({ params }: { params: Promise<{ slug: string }> }) {
|
||||
const { slug } = await params;
|
||||
const news = NEWS.find((n) => n.id === slug);
|
||||
|
||||
if (!news) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const serializedNews = JSON.parse(JSON.stringify(news));
|
||||
return <NewsDetailClient news={serializedNews} />;
|
||||
}
|
||||
Reference in New Issue
Block a user