refactor: Move Navbar and Footer to global RootLayout, deduplicating page imports

This commit is contained in:
AyrisAI
2026-07-12 20:54:22 +03:00
parent f696d359b0
commit 2f2dafcfb9
11 changed files with 10 additions and 45 deletions
+9
View File
@@ -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>