@@ -10,14 +10,15 @@ import { cache, PropsWithChildren } from 'react';
1010
1111import '../../globals.css' ;
1212
13+ import { Streamable } from '@/vibes/soul/lib/streamable' ;
1314import { fonts } from '~/app/fonts' ;
1415import { CookieNotifications } from '~/app/notifications' ;
1516import { Providers } from '~/app/providers' ;
1617import { client } from '~/client' ;
1718import { graphql } from '~/client/graphql' ;
1819import { revalidate } from '~/client/revalidate-target' ;
1920import { WebAnalyticsFragment } from '~/components/analytics/fragment' ;
20- import { AnalyticsProvider } from '~/components/analytics/provider' ;
21+ import { StreamableAnalyticsProvider } from '~/components/analytics/streamable- provider' ;
2122import { ContainerQueryPolyfill } from '~/components/polyfills/container-query' ;
2223import { ScriptManagerScripts , ScriptsFragment } from '~/components/scripts' ;
2324import { routing } from '~/i18n/routing' ;
@@ -100,7 +101,7 @@ interface Props extends PropsWithChildren {
100101export default async function RootLayout ( { params, children } : Props ) {
101102 const { locale } = await params ;
102103
103- const { data } = await fetchRootLayoutMetadata ( ) ;
104+ const rootData = await fetchRootLayoutMetadata ( ) ;
104105 const toastNotificationCookieData = await getToastNotification ( ) ;
105106
106107 if ( ! routing . locales . includes ( locale ) ) {
@@ -111,30 +112,41 @@ export default async function RootLayout({ params, children }: Props) {
111112 // https://next-intl-docs.vercel.app/docs/getting-started/app-router#add-setRequestLocale-to-all-layouts-and-pages
112113 setRequestLocale ( locale ) ;
113114
115+ const streamableAnalyticsData = Streamable . from ( async ( ) => {
116+ const { data } = await fetchRootLayoutMetadata ( ) ;
117+
118+ return {
119+ channelId : data . channel . entityId ,
120+ settings : data . site . settings ,
121+ } ;
122+ } ) ;
123+
114124 return (
115125 < html className = { clsx ( fonts . map ( ( f ) => f . variable ) ) } lang = { locale } >
116126 < head >
117127 < ScriptManagerScripts
118- scripts = { data . site . content . headerScripts }
128+ scripts = { rootData . data . site . content . headerScripts }
119129 strategy = "afterInteractive"
120130 />
121131 </ head >
122132 < body className = "flex min-h-screen flex-col" >
123133 < NextIntlClientProvider >
124134 < NuqsAdapter >
125- < AnalyticsProvider channelId = { data . channel . entityId } settings = { data . site . settings } >
126- < Providers >
127- { toastNotificationCookieData && (
128- < CookieNotifications { ...toastNotificationCookieData } />
129- ) }
130- { children }
131- </ Providers >
132- </ AnalyticsProvider >
135+ < StreamableAnalyticsProvider data = { streamableAnalyticsData } />
136+ < Providers >
137+ { toastNotificationCookieData && (
138+ < CookieNotifications { ...toastNotificationCookieData } />
139+ ) }
140+ { children }
141+ </ Providers >
133142 </ NuqsAdapter >
134143 </ NextIntlClientProvider >
135144 < VercelComponents />
136145 < ContainerQueryPolyfill />
137- < ScriptManagerScripts scripts = { data . site . content . footerScripts } strategy = "lazyOnload" />
146+ < ScriptManagerScripts
147+ scripts = { rootData . data . site . content . footerScripts }
148+ strategy = "lazyOnload"
149+ />
138150 </ body >
139151 </ html >
140152 ) ;
0 commit comments