fix: there can only ever be one root layout, and it should always contains html and body tags

This commit is contained in:
Simon Emanuelsson
2025-04-01 14:30:56 +02:00
parent e45fea6de4
commit d513184be4
6 changed files with 16 additions and 20 deletions

View File

@@ -22,21 +22,24 @@ import GTMScript from "@/components/TrackingSDK/GTMScript"
import RouterTracking from "@/components/TrackingSDK/RouterTracking" import RouterTracking from "@/components/TrackingSDK/RouterTracking"
import { getIntl } from "@/i18n" import { getIntl } from "@/i18n"
import ServerIntlProvider from "@/i18n/Provider" import ServerIntlProvider from "@/i18n/Provider"
import { setLang } from "@/i18n/serverContext"
import type { LangParams, LayoutArgs } from "@/types/params" import type { LangParams, LayoutArgs } from "@/types/params"
export default async function RootLayout({ export default async function RootLayout({
bookingwidget, bookingwidget,
children, children,
params,
}: React.PropsWithChildren< }: React.PropsWithChildren<
LayoutArgs<LangParams> & { LayoutArgs<LangParams> & {
bookingwidget: React.ReactNode bookingwidget: React.ReactNode
} }
>) { >) {
setLang(params.lang)
const { defaultLocale, locale, messages } = await getIntl() const { defaultLocale, locale, messages } = await getIntl()
return ( return (
<> <html lang={params.lang}>
<head> <head>
<AdobeSDKScript /> <AdobeSDKScript />
<GTMScript /> <GTMScript />
@@ -71,6 +74,6 @@ export default async function RootLayout({
</ServerIntlProvider> </ServerIntlProvider>
</SessionProvider> </SessionProvider>
</body> </body>
</> </html>
) )
} }

View File

@@ -15,6 +15,7 @@ import SkipToMainContent from "@/components/SkipToMainContent"
import RouterTracking from "@/components/TrackingSDK/RouterTracking" import RouterTracking from "@/components/TrackingSDK/RouterTracking"
import { getIntl } from "@/i18n" import { getIntl } from "@/i18n"
import ServerIntlProvider from "@/i18n/Provider" import ServerIntlProvider from "@/i18n/Provider"
import { setLang } from "@/i18n/serverContext"
import type { Metadata } from "next" import type { Metadata } from "next"
@@ -33,6 +34,7 @@ export default async function RootLayout({
}: React.PropsWithChildren< }: React.PropsWithChildren<
LayoutArgs<LangParams> & { header: React.ReactNode } LayoutArgs<LangParams> & { header: React.ReactNode }
>) { >) {
setLang(params.lang)
const { defaultLocale, locale, messages } = await getIntl() const { defaultLocale, locale, messages } = await getIntl()
return ( return (

View File

@@ -18,16 +18,19 @@ import GTMScript from "@/components/TrackingSDK/GTMScript"
import RouterTracking from "@/components/TrackingSDK/RouterTracking" import RouterTracking from "@/components/TrackingSDK/RouterTracking"
import { getIntl } from "@/i18n" import { getIntl } from "@/i18n"
import ServerIntlProvider from "@/i18n/Provider" import ServerIntlProvider from "@/i18n/Provider"
import { setLang } from "@/i18n/serverContext"
import type { LangParams, LayoutArgs } from "@/types/params" import type { LangParams, LayoutArgs } from "@/types/params"
export default async function RootLayout({ export default async function RootLayout({
children, children,
params,
}: React.PropsWithChildren<LayoutArgs<LangParams>>) { }: React.PropsWithChildren<LayoutArgs<LangParams>>) {
setLang(params.lang)
const { defaultLocale, locale, messages } = await getIntl() const { defaultLocale, locale, messages } = await getIntl()
return ( return (
<> <html lang={params.lang}>
<head> <head>
<AdobeSDKScript /> <AdobeSDKScript />
<GTMScript /> <GTMScript />
@@ -58,6 +61,6 @@ export default async function RootLayout({
</ServerIntlProvider> </ServerIntlProvider>
</SessionProvider> </SessionProvider>
</body> </body>
</> </html>
) )
} }

View File

@@ -19,6 +19,7 @@ import GTMScript from "@/components/TrackingSDK/GTMScript"
import RouterTracking from "@/components/TrackingSDK/RouterTracking" import RouterTracking from "@/components/TrackingSDK/RouterTracking"
import { getIntl } from "@/i18n" import { getIntl } from "@/i18n"
import ServerIntlProvider from "@/i18n/Provider" import ServerIntlProvider from "@/i18n/Provider"
import { setLang } from "@/i18n/serverContext"
import type { LangParams, LayoutArgs } from "@/types/params" import type { LangParams, LayoutArgs } from "@/types/params"
@@ -29,6 +30,7 @@ export default async function RootLayout({
if (!env.SAS_ENABLED) { if (!env.SAS_ENABLED) {
return null return null
} }
setLang(params.lang)
const { defaultLocale, locale, messages } = await getIntl() const { defaultLocale, locale, messages } = await getIntl()

View File

@@ -1,16 +0,0 @@
import { getLang, setLang } from "@/i18n/serverContext"
import type { Lang } from "@/constants/languages"
export default function Layout({
children,
params,
}: {
children: React.ReactNode
params: { lang: Lang }
}) {
setLang(params.lang)
const lang = getLang()
return <html lang={lang}>{children}</html>
}

View File

@@ -14,6 +14,7 @@ import GTMScript from "@/components/TrackingSDK/GTMScript"
import RouterTracking from "@/components/TrackingSDK/RouterTracking" import RouterTracking from "@/components/TrackingSDK/RouterTracking"
import { getIntl } from "@/i18n" import { getIntl } from "@/i18n"
import ServerIntlProvider from "@/i18n/Provider" import ServerIntlProvider from "@/i18n/Provider"
import { setLang } from "@/i18n/serverContext"
import styles from "./layout.module.css" import styles from "./layout.module.css"
@@ -29,6 +30,7 @@ export default async function RootLayout({
children, children,
params, params,
}: React.PropsWithChildren<LayoutArgs<LangParams>>) { }: React.PropsWithChildren<LayoutArgs<LangParams>>) {
setLang(params.lang)
const { defaultLocale, locale, messages } = await getIntl() const { defaultLocale, locale, messages } = await getIntl()
return ( return (