This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
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";
|
||||
|
||||
@@ -13,11 +15,17 @@ type SiteLayoutProps = {
|
||||
};
|
||||
};
|
||||
|
||||
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) {
|
||||
if (maintenanceEnabled && !authenticated) {
|
||||
redirect(`/${localeKey}/coming-soon`);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { unstable_noStore as noStore } from "next/cache";
|
||||
import { NextIntlClientProvider } from "next-intl";
|
||||
import { getMessages, setRequestLocale } from "next-intl/server";
|
||||
import { notFound } from "next/navigation";
|
||||
@@ -13,6 +14,9 @@ type LocaleLayoutProps = {
|
||||
};
|
||||
};
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
export const revalidate = 0;
|
||||
|
||||
export function generateStaticParams() {
|
||||
return routing.locales.map((locale) => ({ locale }));
|
||||
}
|
||||
@@ -21,6 +25,8 @@ export default async function LocaleLayout({
|
||||
children,
|
||||
params: { locale },
|
||||
}: LocaleLayoutProps) {
|
||||
noStore();
|
||||
|
||||
if (!routing.locales.includes(locale as (typeof routing.locales)[number])) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
+6
-1
@@ -23,6 +23,7 @@ import {
|
||||
resetAdminFailedAttempts,
|
||||
setAdminSessionCookie,
|
||||
} from "@/lib/admin-auth";
|
||||
import { routing } from "@/i18n/routing";
|
||||
import { getMaintenanceMode, setMaintenanceMode } from "@/lib/app-config";
|
||||
import { resolveLocale } from "@/lib/site-data";
|
||||
|
||||
@@ -86,8 +87,12 @@ export default async function RootPage({ searchParams }: RootPageProps) {
|
||||
const nextValue = formData.get("enabled") === "true";
|
||||
|
||||
await setMaintenanceMode(nextValue);
|
||||
revalidatePath("/", "layout");
|
||||
revalidatePath("/root");
|
||||
revalidatePath(`/${localeKey}/coming-soon`);
|
||||
for (const appLocale of routing.locales) {
|
||||
revalidatePath(`/${appLocale}`, "layout");
|
||||
revalidatePath(`/${appLocale}/coming-soon`);
|
||||
}
|
||||
redirect("/root");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user