refactor: Move Navbar and Footer to global RootLayout, deduplicating page imports
This commit is contained in:
@@ -4,6 +4,9 @@ import { NextIntlClientProvider } from 'next-intl';
|
||||
import { getMessages, setRequestLocale } from 'next-intl/server';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { routing } from '@/i18n/routing';
|
||||
import { headers } from 'next/headers';
|
||||
import Navbar from '@/components/Navbar';
|
||||
import Footer from '@/components/Footer';
|
||||
import "../globals.css";
|
||||
|
||||
const unbounded = Unbounded({
|
||||
@@ -50,6 +53,10 @@ export default async function RootLayout({
|
||||
setRequestLocale(locale);
|
||||
const messages = await getMessages();
|
||||
|
||||
const headersList = await headers();
|
||||
const pathname = headersList.get('x-pathname') || '';
|
||||
const hideNavbarFooter = pathname.includes('/admin') || pathname.includes('/login');
|
||||
|
||||
return (
|
||||
<html
|
||||
lang={locale}
|
||||
@@ -57,7 +64,9 @@ export default async function RootLayout({
|
||||
>
|
||||
<body className="min-h-full flex flex-col font-sans" suppressHydrationWarning>
|
||||
<NextIntlClientProvider messages={messages}>
|
||||
{!hideNavbarFooter && <Navbar />}
|
||||
{children}
|
||||
{!hideNavbarFooter && <Footer />}
|
||||
</NextIntlClientProvider>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user