diff --git a/src/app/(frontend)/layout.tsx b/src/app/(frontend)/layout.tsx index ea697f4..8186f14 100644 --- a/src/app/(frontend)/layout.tsx +++ b/src/app/(frontend)/layout.tsx @@ -1,6 +1,4 @@ import type { Metadata } from 'next' -import { getPayload } from 'payload' -import config from '@payload-config' import { AnnouncementBarComponent } from '@/components/AnnouncementBar/AnnouncementBar' import { cn } from '@/utilities/ui' import { GeistMono } from 'geist/font/mono' @@ -21,27 +19,14 @@ import { PopupAnnouncementComponent } from '@/globals/PopupAnnouncement/Componen import './globals.css' import { getServerSideURL } from '@/utilities/getURL' -async function AnnouncementBarWrapper() { - const payload = await getPayload({ config }) - const announcement = await payload.findGlobal({ slug: 'announcement-bar' }) - if (!announcement?.enabled) return null - return ( - - ) -} - export default async function RootLayout({ children }: { children: React.ReactNode }) { const { isEnabled } = await draftMode() - const [siteSettings, popupData] = await Promise.all([ + // All three globals fetched once via the ISR cache — no direct DB hits downstream + const [siteSettings, popupData, announcement] = await Promise.all([ getCachedGlobal('site-settings', 1)() as any, getCachedGlobal('popup-announcement', 1)() as any, + getCachedGlobal('announcement-bar', 1)() as any, ]) const cc = siteSettings?.cookieConsent @@ -66,12 +51,20 @@ export default async function RootLayout({ children }: { children: React.ReactNo - + - + {announcement?.enabled && ( + + )}
{children}