42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import type { ReactNode } from "react";
|
|
import { notFound, redirect } from "next/navigation";
|
|
import BottomNav from "@/components/BottomNav";
|
|
import SiteFooter from "@/components/SiteFooter";
|
|
import SiteHeader from "@/components/SiteHeader";
|
|
import { getActiveLocale, getDictionary, getDirection, getEnabledLocales, isLocale, type Locale } from "@/lib/i18n";
|
|
import { isComingSoonMode } from "@/lib/site";
|
|
|
|
export const dynamicParams = false;
|
|
|
|
export function generateStaticParams() {
|
|
return getEnabledLocales().map((locale) => ({ locale }));
|
|
}
|
|
|
|
export default function LocaleLayout({
|
|
children,
|
|
params,
|
|
}: {
|
|
children: ReactNode;
|
|
params: { locale: string };
|
|
}) {
|
|
if (!isLocale(params.locale)) {
|
|
notFound();
|
|
}
|
|
|
|
if (isComingSoonMode()) {
|
|
redirect("/");
|
|
}
|
|
|
|
const locale = getActiveLocale(params.locale as Locale);
|
|
const dictionary = getDictionary(locale);
|
|
|
|
return (
|
|
<div dir={getDirection(locale)} className="site-shell">
|
|
<SiteHeader locale={locale} common={dictionary.common} />
|
|
<main className="page-content">{children}</main>
|
|
<BottomNav locale={locale} common={dictionary.common} />
|
|
<SiteFooter locale={locale} common={dictionary.common} />
|
|
</div>
|
|
);
|
|
}
|