Merged in feature/refactor-lang (pull request #387)
feat: SW-238 Avoid prop drilling of lang Approved-by: Michael Zetterberg
This commit is contained in:
@@ -4,6 +4,7 @@ import Footer from "@/components/Current/Footer"
|
||||
import LangPopup from "@/components/Current/LangPopup"
|
||||
import InitLivePreview from "@/components/Current/LivePreview"
|
||||
import SkipToMainContent from "@/components/SkipToMainContent"
|
||||
import { getLang, setLang } from "@/i18n/serverContext"
|
||||
|
||||
import type { Metadata } from "next"
|
||||
|
||||
@@ -20,8 +21,10 @@ export default function RootLayout({
|
||||
children,
|
||||
params,
|
||||
}: React.PropsWithChildren<LayoutArgs<LangParams>>) {
|
||||
setLang(params.lang)
|
||||
|
||||
return (
|
||||
<html lang={params.lang}>
|
||||
<html lang={getLang()}>
|
||||
<head>
|
||||
{/* eslint-disable-next-line @next/next/no-css-tags */}
|
||||
<link rel="stylesheet" href="/_static/css/core.css" />
|
||||
@@ -30,10 +33,10 @@ export default function RootLayout({
|
||||
</head>
|
||||
<body>
|
||||
<InitLivePreview />
|
||||
<LangPopup lang={params.lang} />
|
||||
<LangPopup />
|
||||
<SkipToMainContent />
|
||||
{children}
|
||||
<Footer lang={params.lang} />
|
||||
<Footer />
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
|
||||
@@ -5,14 +5,18 @@ import { GetCurrentBlockPage } from "@/lib/graphql/Query/CurrentBlockPage.graphq
|
||||
|
||||
import ContentPage from "@/components/Current/ContentPage"
|
||||
import LoadingSpinner from "@/components/Current/LoadingSpinner"
|
||||
import { getLang, setLang } from "@/i18n/serverContext"
|
||||
|
||||
import type { LangParams, PageArgs, PreviewParams } from "@/types/params"
|
||||
import type { PageArgs, PreviewParams } from "@/types/params"
|
||||
import { LangParams } from "@/types/params"
|
||||
import type { GetCurrentBlockPageData } from "@/types/requests/currentBlockPage"
|
||||
|
||||
export default async function CurrentPreviewPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: PageArgs<LangParams, PreviewParams>) {
|
||||
setLang(params.lang)
|
||||
|
||||
try {
|
||||
ContentstackLivePreview.setConfigFromParams(searchParams)
|
||||
|
||||
@@ -22,7 +26,7 @@ export default async function CurrentPreviewPage({
|
||||
|
||||
const response = await previewRequest<GetCurrentBlockPageData>(
|
||||
GetCurrentBlockPage,
|
||||
{ locale: params.lang, url: searchParams.uri }
|
||||
{ locale: getLang(), url: searchParams.uri }
|
||||
)
|
||||
|
||||
if (!response.data?.all_current_blocks_page?.total) {
|
||||
|
||||
Reference in New Issue
Block a user