dont install the scripts on booking pages (#20373)
This commit is contained in:
+5
-1
@@ -434,4 +434,8 @@ NEXT_PUBLIC_QUERY_AVAILABLE_SLOTS_INTERVAL_SECONDS=
|
||||
# Used to invalidate available slots when navigating to booking form
|
||||
NEXT_PUBLIC_INVALIDATE_AVAILABLE_SLOTS_ON_BOOKING_FORM=0
|
||||
# Used to enable quick availability checks for x% of all visitors
|
||||
NEXT_PUBLIC_QUICK_AVAILABILITY_ROLLOUT=10
|
||||
NEXT_PUBLIC_QUICK_AVAILABILITY_ROLLOUT=10
|
||||
|
||||
# Deprecated. Use NEXT_PUBLIC_BODY_SCRIPTS instead. NEXT_PUBLIC_HEAD_SCRIPTS are now injected into the body only.
|
||||
NEXT_PUBLIC_HEAD_SCRIPTS=
|
||||
NEXT_PUBLIC_BODY_SCRIPTS=
|
||||
@@ -1,14 +1,39 @@
|
||||
import { headers } from "next/headers";
|
||||
import Script from "next/script";
|
||||
|
||||
import PageWrapper from "@components/PageWrapperAppDir";
|
||||
|
||||
export default async function PageWrapperLayout({ children }: { children: React.ReactNode }) {
|
||||
const h = await headers();
|
||||
const nonce = h.get("x-nonce") ?? undefined;
|
||||
const headScript = process.env.NEXT_PUBLIC_HEAD_SCRIPTS;
|
||||
const bodyScript = process.env.NEXT_PUBLIC_BODY_SCRIPTS;
|
||||
|
||||
const scripts = [
|
||||
{
|
||||
id: "injected-head-script",
|
||||
script: headScript ?? "",
|
||||
},
|
||||
{
|
||||
id: "injected-body-script",
|
||||
script: bodyScript ?? "",
|
||||
},
|
||||
].filter((script): script is { id: string; script: string } => !!script.script);
|
||||
|
||||
return (
|
||||
<PageWrapper requiresLicense={false} nonce={nonce}>
|
||||
{children}
|
||||
{scripts.map((script) => (
|
||||
<Script
|
||||
key={script.id}
|
||||
nonce={nonce}
|
||||
id={script.id}
|
||||
// eslint-disable-next-line react/no-danger
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: script.script,
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</PageWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -116,16 +116,6 @@ export default async function RootLayout({ children }: { children: React.ReactNo
|
||||
suppressHydrationWarning
|
||||
data-nextjs-router="app">
|
||||
<head nonce={nonce}>
|
||||
{!!process.env.NEXT_PUBLIC_HEAD_SCRIPTS && (
|
||||
<script
|
||||
nonce={nonce}
|
||||
id="injected-head-scripts"
|
||||
// eslint-disable-next-line react/no-danger
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: process.env.NEXT_PUBLIC_HEAD_SCRIPTS,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<style>{`
|
||||
:root {
|
||||
--font-inter: ${interFont.style.fontFamily.replace(/\'/g, "")};
|
||||
@@ -150,16 +140,6 @@ export default async function RootLayout({ children }: { children: React.ReactNo
|
||||
}
|
||||
}>
|
||||
<IconSprites />
|
||||
{!!process.env.NEXT_PUBLIC_BODY_SCRIPTS && (
|
||||
<script
|
||||
nonce={nonce}
|
||||
id="injected-head-scripts"
|
||||
// eslint-disable-next-line react/no-danger
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: process.env.NEXT_PUBLIC_BODY_SCRIPTS,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<SpeculationRules
|
||||
// URLs In Navigation
|
||||
prerenderPathsOnHover={[
|
||||
|
||||
Reference in New Issue
Block a user