Enforce maintenance mode in site layout instead of middleware fetch
CI / quality (push) Waiting to run
CI / quality (push) Waiting to run
This commit is contained in:
@@ -1,13 +1,26 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import { Footer } from "@/components/footer";
|
||||
import { Navbar } from "@/components/navbar";
|
||||
import { getMaintenanceMode } from "@/lib/app-config";
|
||||
import { resolveLocale } from "@/lib/site-data";
|
||||
|
||||
type SiteLayoutProps = {
|
||||
children: ReactNode;
|
||||
params: {
|
||||
locale: string;
|
||||
};
|
||||
};
|
||||
|
||||
export default function SiteLayout({ children }: SiteLayoutProps) {
|
||||
export default async function SiteLayout({ children, params: { locale } }: SiteLayoutProps) {
|
||||
const localeKey = resolveLocale(locale);
|
||||
const maintenanceEnabled = await getMaintenanceMode();
|
||||
|
||||
if (maintenanceEnabled) {
|
||||
redirect(`/${localeKey}/coming-soon`);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen flex-col">
|
||||
<Navbar />
|
||||
|
||||
Reference in New Issue
Block a user