Skip to content

Commit

Permalink
fix: language html attribute issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelbr committed Dec 11, 2024
1 parent 56c8b8a commit c2715c0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 37 deletions.
58 changes: 33 additions & 25 deletions src/app/(main)/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import localFont from "next/font/local";
import { draftMode } from "next/headers";
import { notFound } from "next/navigation";
import { NextIntlClientProvider } from "next-intl";
Expand Down Expand Up @@ -26,6 +27,11 @@ import {
import { loadStudioQuery } from "studio/lib/store";
import "src/styles/global.css";

const fontBrittiSans = localFont({
src: "../../../../public/_assets/britti-sans-variable.woff2",
variable: "--font-britti-sans",
});

const hasValidData = (data: unknown) => data && Object.keys(data).length > 0;

export default async function Layout({
Expand Down Expand Up @@ -76,30 +82,32 @@ export default async function Layout({
const hasFooterData = hasNavData && initialNav.data.footer;

return (
<div>
<NextIntlClientProvider messages={messages}>
<SkipToMain />
{children}
{hasFooterData && isDraftMode ? (
<FooterPreview
initialNav={initialNav}
initialCompanyInfo={initialCompanyInfo}
initialBrandAssets={initialBrandAssets}
initialSoMe={initialSoMe}
initialLegal={initialLegal}
language={params.locale}
/>
) : (
<Footer
navigationData={initialNav.data}
legalData={initialLegal.data}
companyInfo={initialCompanyInfo.data}
brandAssets={initialBrandAssets.data}
soMeData={initialSoMe.data}
/>
)}
{draftMode().isEnabled && <LiveVisualEditing />}
</NextIntlClientProvider>
</div>
<html lang={params.locale}>
<body className={fontBrittiSans.variable}>
<NextIntlClientProvider messages={messages}>
<SkipToMain />
{children}
{hasFooterData && isDraftMode ? (
<FooterPreview
initialNav={initialNav}
initialCompanyInfo={initialCompanyInfo}
initialBrandAssets={initialBrandAssets}
initialSoMe={initialSoMe}
initialLegal={initialLegal}
language={params.locale}
/>
) : (
<Footer
navigationData={initialNav.data}
legalData={initialLegal.data}
companyInfo={initialCompanyInfo.data}
brandAssets={initialBrandAssets.data}
soMeData={initialSoMe.data}
/>
)}
{draftMode().isEnabled && <LiveVisualEditing />}
</NextIntlClientProvider>
</body>
</html>
);
}
14 changes: 2 additions & 12 deletions src/app/layout.tsx → src/app/shared/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
import localFont from "next/font/local";
import { draftMode } from "next/headers";

import LiveVisualEditing from "studio/lib/loaders/AutomaticVisualEditing";

import "src/styles/global.css";

const fontBrittiSans = localFont({
src: "../../public/_assets/britti-sans-variable.woff2",
variable: "--font-britti-sans",
});

export default async function RootLayout({
children,
params,
}: Readonly<{
children: React.ReactNode;
params: {
locale: string;
};
}>) {
return (
<html lang={params.locale}>
<body className={fontBrittiSans.variable}>
<html>
<body>
{children}
{draftMode().isEnabled && <LiveVisualEditing />}
</body>
Expand Down
20 changes: 20 additions & 0 deletions src/app/studio/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { draftMode } from "next/headers";

import LiveVisualEditing from "studio/lib/loaders/AutomaticVisualEditing";

import "src/styles/global.css";

export default async function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html>
<body>
{children}
{draftMode().isEnabled && <LiveVisualEditing />}
</body>
</html>
);
}

0 comments on commit c2715c0

Please sign in to comment.