import { dir } from "i18next"; import { Inter } from "next/font/google"; import localFont from "next/font/local"; import { headers, cookies } from "next/headers"; import React from "react"; import { getLocale } from "@calcom/features/auth/lib/getLocale"; import { prepareRootMetadata } from "@lib/metadata"; import "../styles/globals.css"; const interFont = Inter({ subsets: ["latin"], variable: "--font-inter", preload: true, display: "swap" }); const calFont = localFont({ src: "../fonts/CalSans-SemiBold.woff2", variable: "--font-cal", preload: true, display: "block", weight: "600", }); export const generateMetadata = () => prepareRootMetadata({ twitterCreator: "@calcom", twitterSite: "@calcom", robots: { index: false, follow: false, }, }); const getInitialProps = async (url: string) => { const { pathname, searchParams } = new URL(url); const isEmbed = pathname.endsWith("/embed") || (searchParams?.get("embedType") ?? null) !== null; const embedColorScheme = searchParams?.get("ui.color-scheme"); const req = { headers: headers(), cookies: cookies() }; const newLocale = await getLocale(req); const direction = dir(newLocale); return { isEmbed, embedColorScheme, locale: newLocale, direction }; }; const getFallbackProps = () => ({ locale: "en", direction: "ltr", isEmbed: false, embedColorScheme: false, }); export default async function RootLayout({ children }: { children: React.ReactNode }) { const h = headers(); const fullUrl = h.get("x-url") ?? ""; const nonce = h.get("x-csp") ?? ""; const isSSG = !fullUrl; const { locale, direction, isEmbed, embedColorScheme } = isSSG ? getFallbackProps() : await getInitialProps(fullUrl); return (
{!!process.env.NEXT_PUBLIC_HEAD_SCRIPTS && ( )} {!!process.env.NEXT_PUBLIC_BODY_SCRIPTS && ( )} {children} ); }