Preview: layout.tsx
Size: 5.11 KB
/var/www/nea-dev-frontend.wpress.dk/httpdocs/src/app/layout.tsx
import './globals.css';
import { getAdGlobalSettings, getFooterSettings, getThemeHeaderSettings } from '@/queries/general';
import { Footer } from '@/components/layout/footer/Footer';
import { Header } from '@/components/layout/header/Header';
import GptScript from '@/components/ads/gpt-script/GptScript';
import { GoogleTagManager } from '@next/third-parties/google';
import GtmPageView from '@/components/analytics/GtmPageView';
import Script from 'next/script';
// import ScriptReinitializer from '@/components/common/script-reinitializer/ScriptReinitializer';
//import WebVitals from '@/components/analytics/web-vitals/WebVitals';
export default async function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
//
const headerData = await getThemeHeaderSettings();
const gtmId = headerData?.gtmId;
const footerData = await getFooterSettings();
const adGlobalSettings = await getAdGlobalSettings();
const cookieYesWebsiteKey = headerData.cookieYesWebsiteKey;
// console.log('headerData', JSON.stringify(headerData));
// console.log('footerData', footerData);
return (
<html lang="en" suppressHydrationWarning={true}>
<head>
{/* Preload critical fonts so they're ready on first paint and avoid FOUT */}
<link
rel="preload"
href="/fonts/Inter-VariableFont_slnt,wght.ttf"
as="font"
type="font/ttf"
crossOrigin="anonymous"
/>
<link
rel="preload"
href="/fonts/DegularVariable.ttf"
as="font"
type="font/ttf"
crossOrigin="anonymous"
/>
<Script
id="gcaptcha-callback"
strategy="beforeInteractive"
dangerouslySetInnerHTML={{
__html: 'window.gCaptchaReadyCallback=function(){};',
}}
/>
<GptScript
googleAdManagerHeaderScript={adGlobalSettings?.googleAdManagerHeaderScript || null}
/>
{/* <Script
src="https://giving.classy.org/embedded/api/sdk/js/47805"
strategy="afterInteractive"
/> */}
{cookieYesWebsiteKey && (
<Script
src={`https://cdn-cookieyes.com/client_data/${cookieYesWebsiteKey}/script.js`}
strategy="beforeInteractive"
/>
)}
</head>
{gtmId && <GoogleTagManager gtmId={gtmId as string} />}
<body>
{gtmId && <GtmPageView />}
{/* <ScriptReinitializer /> */}
{/* <WebVitals /> */}
<Header
utilityLinks={headerData.utilityMenus ? headerData.utilityMenus : null}
megaMenuData={headerData.megaMenuData ? headerData.megaMenuData : null}
themeHeaderSettings={
headerData.themeHeaderSettings ? headerData.themeHeaderSettings : null
}
/>
<main className="main" id="main-content">
{children}
</main>
<Script
id="embedded-giving"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `
document.addEventListener('DOMContentLoaded', (event) => {
(function (win) {
win.egProps = {
campaigns: [
{
campaignId: '494714',
customDomain: 'donate.nationaleczema.org',
donation: {
modal: {
urlParams: { egfa: true },
elementSelector: '#donate',
},
nudgeTrays: [
{
title: 'Reminder 💜',
content:
'Complete your gift to help improve the lives of people with eczema.',
ctaLabel: 'Give Now!',
ctaColor: '#0926ad',
triggerEvent: 'eg:donation:incomplete',
},
],
},
},
],
};
win.document.body.appendChild(makeEGScript());
function makeEGScript() {
var egScript = win.document.createElement('script');
egScript.setAttribute('type', 'text/javascript');
egScript.setAttribute('async', 'true');
egScript.setAttribute(
'src',
'https://sdk.classy.org/embedded-giving.js',
);
return egScript;
}
function readURLParams() {
const searchParams = new URLSearchParams(location.search);
const validUrlParams = ['c_src', 'c_src2'];
return validUrlParams.reduce(function toURLParamsMap(
urlParamsSoFar,
validKey,
) {
const value = searchParams.get(validKey);
return value === null
? urlParamsSoFar
: { ...urlParamsSoFar, [validKey]: value };
},
{});
}
})(window);
});
`.trim(),
}}
/>
<Footer {...footerData} />
</body>
</html>
);
}
Directory Contents
Dirs: 9 × Files: 6