Files
gitlab-instance-0a899031_di…/app/[locale]/layout.tsx
2026-03-08 04:30:57 -05:00

38 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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>
);
}