40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import type { ReactNode } from "react";
|
|
import { unstable_noStore as noStore } from "next/cache";
|
|
import { redirect } from "next/navigation";
|
|
|
|
import { Footer } from "@/components/footer";
|
|
import { Navbar } from "@/components/navbar";
|
|
import { isAdminAuthenticated } from "@/lib/admin-auth";
|
|
import { getMaintenanceMode } from "@/lib/app-config";
|
|
import { resolveLocale } from "@/lib/site-data";
|
|
|
|
type SiteLayoutProps = {
|
|
children: ReactNode;
|
|
params: {
|
|
locale: string;
|
|
};
|
|
};
|
|
|
|
export const dynamic = "force-dynamic";
|
|
export const revalidate = 0;
|
|
|
|
export default async function SiteLayout({ children, params: { locale } }: SiteLayoutProps) {
|
|
noStore();
|
|
|
|
const localeKey = resolveLocale(locale);
|
|
const maintenanceEnabled = await getMaintenanceMode();
|
|
const authenticated = isAdminAuthenticated();
|
|
|
|
if (maintenanceEnabled && !authenticated) {
|
|
redirect(`/${localeKey}/coming-soon`);
|
|
}
|
|
|
|
return (
|
|
<div className="flex min-h-screen flex-col">
|
|
<Navbar isAdmin={authenticated} />
|
|
<main className="flex-1">{children}</main>
|
|
<Footer isAdmin={authenticated} />
|
|
</div>
|
|
);
|
|
}
|