38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import type { Metadata } from "next";
|
||
import { notFound } from "next/navigation";
|
||
import { LocaleProvider } from "../context/LocaleContext";
|
||
import type { Locale } from "../context/LocaleContext";
|
||
|
||
const LOCALES: Locale[] = ["zh", "en"];
|
||
|
||
export const metadata: Metadata = {
|
||
title: "数字游民指南 | Digital Nomad Guide",
|
||
description:
|
||
"从零开始,7天开启你的数字游民生活。远程工作、地点自由、技能变现 —— 一站式数字游民资源平台。",
|
||
};
|
||
|
||
export function generateStaticParams() {
|
||
return LOCALES.map((locale) => ({ locale }));
|
||
}
|
||
|
||
export default async function LocaleLayout({
|
||
children,
|
||
params,
|
||
}: {
|
||
children: React.ReactNode;
|
||
params: Promise<{ locale: string }>;
|
||
}) {
|
||
const { locale } = await params;
|
||
if (!LOCALES.includes(locale as Locale)) {
|
||
notFound();
|
||
}
|
||
|
||
const messages = (await import(`../../messages/${locale}.json`)).default;
|
||
|
||
return (
|
||
<LocaleProvider locale={locale as Locale} messages={messages}>
|
||
{children}
|
||
</LocaleProvider>
|
||
);
|
||
}
|