Fix dynamic default locale routing
This commit is contained in:
@@ -6,7 +6,7 @@ import { SiteAmbientBackdrop } from "@/components/layout/site-ambient-backdrop";
|
||||
import { SiteFooter } from "@/components/layout/site-footer";
|
||||
import { SiteHeader } from "@/components/layout/site-header";
|
||||
import { isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getMaintenanceMode, getSiteSettingsMediaBindings } from "@/lib/app-config";
|
||||
import { getMaintenanceMode, getSiteSettings, getSiteSettingsMediaBindings } from "@/lib/app-config";
|
||||
import { getLocalizedPath, resolveLocale } from "@/lib/locale";
|
||||
|
||||
type SiteLayoutProps = {
|
||||
@@ -24,14 +24,15 @@ export default async function SiteLayout({ children, params }: SiteLayoutProps)
|
||||
const { locale } = await params;
|
||||
|
||||
const localeKey = resolveLocale(locale);
|
||||
const [maintenanceEnabled, mediaBindings] = await Promise.all([
|
||||
const [maintenanceEnabled, mediaBindings, siteSettings] = await Promise.all([
|
||||
getMaintenanceMode(),
|
||||
getSiteSettingsMediaBindings(),
|
||||
getSiteSettings(),
|
||||
]);
|
||||
const authenticated = await isAdminAuthenticated();
|
||||
|
||||
if (maintenanceEnabled && !authenticated) {
|
||||
redirect(getLocalizedPath(localeKey, "/coming-soon"));
|
||||
redirect(getLocalizedPath(localeKey, "/coming-soon", siteSettings.defaultLocale));
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -40,9 +41,10 @@ export default async function SiteLayout({ children, params }: SiteLayoutProps)
|
||||
<SiteHeader
|
||||
lightLogoUrl={mediaBindings.siteLogoLight?.url}
|
||||
darkLogoUrl={mediaBindings.siteLogoDark?.url}
|
||||
defaultLocale={siteSettings.defaultLocale}
|
||||
/>
|
||||
<main className="flex-1">{children}</main>
|
||||
<SiteFooter />
|
||||
<SiteFooter defaultLocale={siteSettings.defaultLocale} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user