refactor: Move Navbar and Footer to global RootLayout, deduplicating page imports
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||
import { mockDb } from '@/lib/mockDb'
|
||||
import Navbar from '@/components/Navbar'
|
||||
import Footer from '@/components/Footer'
|
||||
import ListingCard from '@/components/ListingCard'
|
||||
import { notFound } from 'next/navigation'
|
||||
import Image from 'next/image'
|
||||
@@ -85,7 +83,6 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
||||
<Navbar />
|
||||
|
||||
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10 flex-1 space-y-10">
|
||||
|
||||
@@ -388,8 +385,6 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
|
||||
)}
|
||||
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||
import { mockDb } from '@/lib/mockDb'
|
||||
import Navbar from '@/components/Navbar'
|
||||
import Footer from '@/components/Footer'
|
||||
import ListingCard from '@/components/ListingCard'
|
||||
import { SlidersHorizontal } from 'lucide-react'
|
||||
|
||||
@@ -51,7 +49,6 @@ export default async function ApartsPage({ params, searchParams }: PageProps) {
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
||||
<Navbar />
|
||||
|
||||
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10 flex-1">
|
||||
|
||||
@@ -154,8 +151,6 @@ export default async function ApartsPage({ params, searchParams }: PageProps) {
|
||||
)}
|
||||
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||
import Navbar from '@/components/Navbar'
|
||||
import Footer from '@/components/Footer'
|
||||
import { Link } from '@/i18n/routing'
|
||||
import { CheckCircle, ShieldAlert, Award, Star } from 'lucide-react'
|
||||
|
||||
@@ -17,7 +15,6 @@ export default async function AboutPage({ params }: AboutPageProps) {
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
||||
<Navbar />
|
||||
|
||||
<main className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-16 flex-1 space-y-12">
|
||||
|
||||
@@ -119,8 +116,6 @@ export default async function AboutPage({ params }: AboutPageProps) {
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||
import Navbar from '@/components/Navbar'
|
||||
import Footer from '@/components/Footer'
|
||||
import ContactForm from './ContactForm'
|
||||
|
||||
interface ContactPageProps {
|
||||
@@ -16,7 +14,6 @@ export default async function ContactPage({ params }: ContactPageProps) {
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
||||
<Navbar />
|
||||
|
||||
<main className="max-w-xl mx-auto px-4 sm:px-6 lg:px-8 py-12 flex-1 w-full">
|
||||
<div className="bg-paper p-8 rounded-3xl border border-pine/8 shadow-sm">
|
||||
@@ -44,8 +41,6 @@ export default async function ContactPage({ params }: ContactPageProps) {
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||
import { mockDb } from '@/lib/mockDb'
|
||||
import Navbar from '@/components/Navbar'
|
||||
import Footer from '@/components/Footer'
|
||||
import BusinessForm from './BusinessForm'
|
||||
|
||||
interface AddBusinessPageProps {
|
||||
@@ -36,7 +34,6 @@ export default async function AddBusinessPage({ params }: AddBusinessPageProps)
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
||||
<Navbar />
|
||||
|
||||
<main className="max-w-2xl mx-auto px-4 sm:px-6 lg:px-8 py-12 flex-1 w-full">
|
||||
<div className="bg-paper p-8 rounded-3xl border border-pine/8 shadow-sm">
|
||||
@@ -72,8 +69,6 @@ export default async function AddBusinessPage({ params }: AddBusinessPageProps)
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||
import { mockDb } from '@/lib/mockDb'
|
||||
import Navbar from '@/components/Navbar'
|
||||
import Footer from '@/components/Footer'
|
||||
import ListingCard from '@/components/ListingCard'
|
||||
import { SlidersHorizontal } from 'lucide-react'
|
||||
|
||||
@@ -51,7 +49,6 @@ export default async function BusinessesPage({ params, searchParams }: PageProps
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
||||
<Navbar />
|
||||
|
||||
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10 flex-1">
|
||||
|
||||
@@ -154,8 +151,6 @@ export default async function BusinessesPage({ params, searchParams }: PageProps
|
||||
)}
|
||||
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { setRequestLocale } from 'next-intl/server'
|
||||
import { mockDb } from '@/lib/mockDb'
|
||||
import Navbar from '@/components/Navbar'
|
||||
import Footer from '@/components/Footer'
|
||||
import ListingCard from '@/components/ListingCard'
|
||||
import { notFound } from 'next/navigation'
|
||||
import { MapPin } from 'lucide-react'
|
||||
@@ -32,7 +30,6 @@ export default async function NeighborhoodPage({ params }: NeighborhoodPageProps
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
||||
<Navbar />
|
||||
|
||||
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12 flex-1">
|
||||
|
||||
@@ -67,8 +64,6 @@ export default async function NeighborhoodPage({ params }: NeighborhoodPageProps
|
||||
)}
|
||||
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||
import { mockDb } from '@/lib/mockDb'
|
||||
import Navbar from '@/components/Navbar'
|
||||
import Footer from '@/components/Footer'
|
||||
import ListingCard from '@/components/ListingCard'
|
||||
import { Link } from '@/i18n/routing'
|
||||
import { Search, MapPin, CheckCircle, ArrowRight } from 'lucide-react'
|
||||
@@ -42,7 +40,6 @@ export default async function HomePage({ params }: { params: Promise<{ locale: s
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
||||
<Navbar />
|
||||
|
||||
{/* Hero Section */}
|
||||
<section className="bg-pine text-stone pt-20 pb-24 relative overflow-hidden">
|
||||
@@ -241,8 +238,6 @@ export default async function HomePage({ params }: { params: Promise<{ locale: s
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||
import { mockDb } from '@/lib/mockDb'
|
||||
import Navbar from '@/components/Navbar'
|
||||
import Footer from '@/components/Footer'
|
||||
import ListingCard from '@/components/ListingCard'
|
||||
import { Link } from '@/i18n/routing'
|
||||
import { MapPin, SlidersHorizontal, Check } from 'lucide-react'
|
||||
@@ -53,7 +51,6 @@ export default async function RestaurantsPage({ params, searchParams }: PageProp
|
||||
|
||||
return (
|
||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
||||
<Navbar />
|
||||
|
||||
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10 flex-1">
|
||||
|
||||
@@ -156,8 +153,6 @@ export default async function RestaurantsPage({ params, searchParams }: PageProp
|
||||
)}
|
||||
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user