diff --git a/bun.lockb b/bun.lockb index 9430d9741..16280d20b 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index bb0e2c15d..276fef651 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "ajv": "^8.12.0", "assert-never": "^1.2.1", "bun-types": "^1.0.7", + "content-security-policy-merger": "^1.0.0", "framer-motion": "^10.16.14", "js-cookie": "^3.0.5", "jsontoxml": "^1.0.1", diff --git a/src/app/[spaceId]/[[...pathname]]/layout.tsx b/src/app/[spaceId]/[[...pathname]]/layout.tsx index 2cbe1f505..c9556fb67 100644 --- a/src/app/[spaceId]/[[...pathname]]/layout.tsx +++ b/src/app/[spaceId]/[[...pathname]]/layout.tsx @@ -1,12 +1,15 @@ import { CustomizationHeaderPreset, CustomizationSettings } from '@gitbook/api'; import assertNever from 'assert-never'; +import Script from 'next/script'; import colors from 'tailwindcss/colors'; import { fonts } from '@/fonts'; +import { getSpaceContent } from '@/lib/api'; import { hexToRgb, shadesOfColor } from '@/lib/colors'; +import { getContentSecurityPolicyNonce } from '@/lib/csp'; import { tcls } from '@/lib/tailwind'; -import { PagePathParams, fetchPageData } from '../fetch'; +import { PagePathParams } from '../fetch'; export default async function SpaceRootLayout(props: { children: React.ReactNode; @@ -14,13 +17,21 @@ export default async function SpaceRootLayout(props: { }) { const { params, children } = props; - const { customization } = await fetchPageData(params); + const { customization, scripts } = await getSpaceContent({ + spaceId: params.spaceId, + }); const headerTheme = generateHeaderTheme(customization); + const nonce = getContentSecurityPolicyNonce(); return ( -