mirror of
https://github.com/KivotosRailway/website.git
synced 2026-11-03 19:07:56 +09:00
优化代码
This commit is contained in:
@@ -1 +1,26 @@
|
||||
export { default, generateMetadata, generateStaticParams } from "@/app/(legacy)/policy/[slug]/page";
|
||||
import type { Metadata } from "next";
|
||||
import { notFound } from "next/navigation";
|
||||
import { PolicyPageContent } from "@/components/policy/policy-page-content";
|
||||
import { getPolicyCatalog, getPolicySlugs } from "@/data/policy";
|
||||
import { isLocale } from "@/lib/i18n";
|
||||
|
||||
export const dynamicParams = false;
|
||||
|
||||
export function generateStaticParams() {
|
||||
return getPolicySlugs();
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: { params: Promise<{ slug: string; locale: string }> }): Promise<Metadata> {
|
||||
const { slug, locale } = await params;
|
||||
if (!isLocale(locale)) notFound();
|
||||
const catalog = await getPolicyCatalog(slug);
|
||||
return { title: catalog[locale]?.title ?? "法律信息" };
|
||||
}
|
||||
|
||||
export default async function PolicyPage({ params }: { params: Promise<{ slug: string; locale: string }> }) {
|
||||
const { slug, locale } = await params;
|
||||
if (!isLocale(locale)) notFound();
|
||||
const catalog = await getPolicyCatalog(slug);
|
||||
if (!catalog["zh-Hans"]) notFound();
|
||||
return <main className="policy-page"><div className="policy-page-inner"><PolicyPageContent catalog={catalog} /></div></main>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user