优化页面数据加载并完善多语言 SEO、新闻回退、主题首屏及自动化回归测试

This commit is contained in:
2026-10-22 19:01:02 +08:00
parent 7eb97cc5e3
commit 873da8b77c
53 changed files with 774 additions and 362 deletions
+6 -2
View File
@@ -2,6 +2,7 @@ import { notFound } from "next/navigation";
import { getNewsBySlug, getNewsList } from "@/data/news";
import { NewsDetailClient } from "@/components/news/news-detail-client";
import { isLocale } from "@/lib/i18n";
import { descriptionFromMarkdown, pageMetadata } from "@/lib/seo";
export async function generateStaticParams() {
return (await getNewsList()).map((item) => ({ slug: item.slug }));
@@ -11,11 +12,14 @@ export async function generateMetadata({ params }: { params: Promise<{ slug: str
const { slug, locale } = await params;
if (!isLocale(locale)) notFound();
const item = await getNewsBySlug(slug, locale);
return { title: item?.title ?? "新闻" };
if (!item) notFound();
return pageMetadata(locale, item.href, { title: item.title, description: descriptionFromMarkdown(item.body), article: true });
}
export default async function NewsDetailPage({ params }: { params: Promise<{ slug: string; locale: string }> }) {
const { slug, locale } = await params;
if (!isLocale(locale)) notFound();
return <NewsDetailClient item={await getNewsBySlug(slug, locale)} locale={locale} />;
const item = await getNewsBySlug(slug, locale);
if (!item) notFound();
return <NewsDetailClient item={item} locale={locale} />;
}