-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayout.tsx
43 lines (40 loc) · 1.73 KB
/
layout.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { SitePreviewProvider } from "@comet/cms-site";
import { GlobalStyle } from "@src/layout/GlobalStyle";
import { ResponsiveSpacingStyle } from "@src/util/ResponsiveSpacingStyle";
import { getSiteConfigForDomain } from "@src/util/siteConfig";
import { SiteConfigProvider } from "@src/util/SiteConfigProvider";
import StyledComponentsRegistry from "@src/util/StyledComponentsRegistry";
import type { Metadata } from "next";
import { draftMode } from "next/headers";
import { PropsWithChildren } from "react";
export const metadata: Metadata = {
title: "Comet Starter",
};
export default async function RootLayout({ children, params: { domain } }: Readonly<PropsWithChildren<{ params: { domain: string } }>>) {
const siteConfig = await getSiteConfigForDomain(domain);
const isDraftModeEnabled = draftMode().isEnabled;
return (
<html>
<head />
<body>
{siteConfig.gtmId && (
<noscript>
<iframe
src={`https://www.googletagmanager.com/ns.html?id=${siteConfig.gtmId}`}
height="0"
width="0"
style={{ display: "none", visibility: "hidden" }}
/>
</noscript>
)}
<StyledComponentsRegistry>
<GlobalStyle />
<ResponsiveSpacingStyle />
<SiteConfigProvider siteConfig={siteConfig}>
{isDraftModeEnabled ? <SitePreviewProvider>{children}</SitePreviewProvider> : children}
</SiteConfigProvider>
</StyledComponentsRegistry>
</body>
</html>
);
}