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 { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||||
import { mockDb } from '@/lib/mockDb'
|
import { mockDb } from '@/lib/mockDb'
|
||||||
import Navbar from '@/components/Navbar'
|
|
||||||
import Footer from '@/components/Footer'
|
|
||||||
import ListingCard from '@/components/ListingCard'
|
import ListingCard from '@/components/ListingCard'
|
||||||
import { notFound } from 'next/navigation'
|
import { notFound } from 'next/navigation'
|
||||||
import Image from 'next/image'
|
import Image from 'next/image'
|
||||||
@@ -85,7 +83,6 @@ export default async function ListingDetailPage({ params }: DetailPageProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
<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">
|
<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>
|
</main>
|
||||||
|
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||||
import { mockDb } from '@/lib/mockDb'
|
import { mockDb } from '@/lib/mockDb'
|
||||||
import Navbar from '@/components/Navbar'
|
|
||||||
import Footer from '@/components/Footer'
|
|
||||||
import ListingCard from '@/components/ListingCard'
|
import ListingCard from '@/components/ListingCard'
|
||||||
import { SlidersHorizontal } from 'lucide-react'
|
import { SlidersHorizontal } from 'lucide-react'
|
||||||
|
|
||||||
@@ -51,7 +49,6 @@ export default async function ApartsPage({ params, searchParams }: PageProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
<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">
|
<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>
|
</main>
|
||||||
|
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||||
import Navbar from '@/components/Navbar'
|
|
||||||
import Footer from '@/components/Footer'
|
|
||||||
import { Link } from '@/i18n/routing'
|
import { Link } from '@/i18n/routing'
|
||||||
import { CheckCircle, ShieldAlert, Award, Star } from 'lucide-react'
|
import { CheckCircle, ShieldAlert, Award, Star } from 'lucide-react'
|
||||||
|
|
||||||
@@ -17,7 +15,6 @@ export default async function AboutPage({ params }: AboutPageProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
<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">
|
<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>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||||
import Navbar from '@/components/Navbar'
|
|
||||||
import Footer from '@/components/Footer'
|
|
||||||
import ContactForm from './ContactForm'
|
import ContactForm from './ContactForm'
|
||||||
|
|
||||||
interface ContactPageProps {
|
interface ContactPageProps {
|
||||||
@@ -16,7 +14,6 @@ export default async function ContactPage({ params }: ContactPageProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
<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">
|
<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">
|
<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>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||||
import { mockDb } from '@/lib/mockDb'
|
import { mockDb } from '@/lib/mockDb'
|
||||||
import Navbar from '@/components/Navbar'
|
|
||||||
import Footer from '@/components/Footer'
|
|
||||||
import BusinessForm from './BusinessForm'
|
import BusinessForm from './BusinessForm'
|
||||||
|
|
||||||
interface AddBusinessPageProps {
|
interface AddBusinessPageProps {
|
||||||
@@ -36,7 +34,6 @@ export default async function AddBusinessPage({ params }: AddBusinessPageProps)
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
<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">
|
<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">
|
<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>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||||
import { mockDb } from '@/lib/mockDb'
|
import { mockDb } from '@/lib/mockDb'
|
||||||
import Navbar from '@/components/Navbar'
|
|
||||||
import Footer from '@/components/Footer'
|
|
||||||
import ListingCard from '@/components/ListingCard'
|
import ListingCard from '@/components/ListingCard'
|
||||||
import { SlidersHorizontal } from 'lucide-react'
|
import { SlidersHorizontal } from 'lucide-react'
|
||||||
|
|
||||||
@@ -51,7 +49,6 @@ export default async function BusinessesPage({ params, searchParams }: PageProps
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
<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">
|
<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>
|
</main>
|
||||||
|
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { NextIntlClientProvider } from 'next-intl';
|
|||||||
import { getMessages, setRequestLocale } from 'next-intl/server';
|
import { getMessages, setRequestLocale } from 'next-intl/server';
|
||||||
import { notFound } from 'next/navigation';
|
import { notFound } from 'next/navigation';
|
||||||
import { routing } from '@/i18n/routing';
|
import { routing } from '@/i18n/routing';
|
||||||
|
import { headers } from 'next/headers';
|
||||||
|
import Navbar from '@/components/Navbar';
|
||||||
|
import Footer from '@/components/Footer';
|
||||||
import "../globals.css";
|
import "../globals.css";
|
||||||
|
|
||||||
const unbounded = Unbounded({
|
const unbounded = Unbounded({
|
||||||
@@ -50,6 +53,10 @@ export default async function RootLayout({
|
|||||||
setRequestLocale(locale);
|
setRequestLocale(locale);
|
||||||
const messages = await getMessages();
|
const messages = await getMessages();
|
||||||
|
|
||||||
|
const headersList = await headers();
|
||||||
|
const pathname = headersList.get('x-pathname') || '';
|
||||||
|
const hideNavbarFooter = pathname.includes('/admin') || pathname.includes('/login');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<html
|
<html
|
||||||
lang={locale}
|
lang={locale}
|
||||||
@@ -57,7 +64,9 @@ export default async function RootLayout({
|
|||||||
>
|
>
|
||||||
<body className="min-h-full flex flex-col font-sans" suppressHydrationWarning>
|
<body className="min-h-full flex flex-col font-sans" suppressHydrationWarning>
|
||||||
<NextIntlClientProvider messages={messages}>
|
<NextIntlClientProvider messages={messages}>
|
||||||
|
{!hideNavbarFooter && <Navbar />}
|
||||||
{children}
|
{children}
|
||||||
|
{!hideNavbarFooter && <Footer />}
|
||||||
</NextIntlClientProvider>
|
</NextIntlClientProvider>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { setRequestLocale } from 'next-intl/server'
|
import { setRequestLocale } from 'next-intl/server'
|
||||||
import { mockDb } from '@/lib/mockDb'
|
import { mockDb } from '@/lib/mockDb'
|
||||||
import Navbar from '@/components/Navbar'
|
|
||||||
import Footer from '@/components/Footer'
|
|
||||||
import ListingCard from '@/components/ListingCard'
|
import ListingCard from '@/components/ListingCard'
|
||||||
import { notFound } from 'next/navigation'
|
import { notFound } from 'next/navigation'
|
||||||
import { MapPin } from 'lucide-react'
|
import { MapPin } from 'lucide-react'
|
||||||
@@ -32,7 +30,6 @@ export default async function NeighborhoodPage({ params }: NeighborhoodPageProps
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
<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">
|
<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>
|
</main>
|
||||||
|
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||||
import { mockDb } from '@/lib/mockDb'
|
import { mockDb } from '@/lib/mockDb'
|
||||||
import Navbar from '@/components/Navbar'
|
|
||||||
import Footer from '@/components/Footer'
|
|
||||||
import ListingCard from '@/components/ListingCard'
|
import ListingCard from '@/components/ListingCard'
|
||||||
import { Link } from '@/i18n/routing'
|
import { Link } from '@/i18n/routing'
|
||||||
import { Search, MapPin, CheckCircle, ArrowRight } from 'lucide-react'
|
import { Search, MapPin, CheckCircle, ArrowRight } from 'lucide-react'
|
||||||
@@ -42,7 +40,6 @@ export default async function HomePage({ params }: { params: Promise<{ locale: s
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
||||||
<Navbar />
|
|
||||||
|
|
||||||
{/* Hero Section */}
|
{/* Hero Section */}
|
||||||
<section className="bg-pine text-stone pt-20 pb-24 relative overflow-hidden">
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
||||||
import { mockDb } from '@/lib/mockDb'
|
import { mockDb } from '@/lib/mockDb'
|
||||||
import Navbar from '@/components/Navbar'
|
|
||||||
import Footer from '@/components/Footer'
|
|
||||||
import ListingCard from '@/components/ListingCard'
|
import ListingCard from '@/components/ListingCard'
|
||||||
import { Link } from '@/i18n/routing'
|
import { Link } from '@/i18n/routing'
|
||||||
import { MapPin, SlidersHorizontal, Check } from 'lucide-react'
|
import { MapPin, SlidersHorizontal, Check } from 'lucide-react'
|
||||||
@@ -53,7 +51,6 @@ export default async function RestaurantsPage({ params, searchParams }: PageProp
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex-1 flex flex-col min-h-screen bg-stone text-ink">
|
<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">
|
<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>
|
</main>
|
||||||
|
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export async function proxy(request: NextRequest) {
|
|||||||
return NextResponse.redirect(new URL('/login', request.url))
|
return NextResponse.redirect(new URL('/login', request.url))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
request.headers.set('x-pathname', request.nextUrl.pathname)
|
||||||
return intlMiddleware(request)
|
return intlMiddleware(request)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user