From e14421ccc0a83a59bd92131f1cd24dbd51c81d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=8E=D1=82=D0=BA=D0=B8=D0=BD=D0=B0=20=D0=94=D0=B0?= =?UTF-8?q?=D1=80=D1=8C=D1=8F=20=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD?= =?UTF-8?q?=D0=B4=D1=80=D0=BE=D0=B2=D0=BD=D0=B0=20=284047910=29?= Date: Fri, 29 Dec 2023 18:24:56 +0400 Subject: [PATCH] fix root layout --- .gitignore | 3 +++ src/app/[locale]/(main)/layout.tsx | 2 +- src/app/[locale]/layout.tsx | 38 ++++++++++++++++++++++++++++++ src/app/layout.tsx | 30 ++--------------------- 4 files changed, 44 insertions(+), 29 deletions(-) create mode 100644 src/app/[locale]/layout.tsx diff --git a/.gitignore b/.gitignore index fd3dbb5..2a4890b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,9 @@ # production /build +# ide +/.idea + # misc .DS_Store *.pem diff --git a/src/app/[locale]/(main)/layout.tsx b/src/app/[locale]/(main)/layout.tsx index 1057990..0f3f494 100644 --- a/src/app/[locale]/(main)/layout.tsx +++ b/src/app/[locale]/(main)/layout.tsx @@ -13,7 +13,7 @@ export async function generateMetadata({ }; } -export default function RootLayout({ children, news, directions, experts, params: { locale } }: { +export default function MainLayout({ children, news, directions, experts, params: { locale } }: { children: ReactNode, news: ReactNode, directions: ReactNode, diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx new file mode 100644 index 0000000..a798f92 --- /dev/null +++ b/src/app/[locale]/layout.tsx @@ -0,0 +1,38 @@ +import React, { ReactNode } from 'react'; +import { Metadata } from 'next'; +import { unstable_setRequestLocale } from 'next-intl/server'; +import { notFound } from 'next/navigation'; +import { ConfigProvider } from 'antd'; +import theme from '../../constants/theme'; +import { ALLOWED_LOCALES } from '../../constants/locale'; +import StyledComponentsRegistry from '../../lib/AntdRegistry'; +import StyledRegistry from '../../lib/StyleRegistry'; + +type LayoutProps = { + children: ReactNode; + params: { locale: string }; +}; + +export function generateStaticParams() { + return ALLOWED_LOCALES.map((locale) => ({ locale })); +} + +export const metadata: Metadata = { + title: 'Bbuddy' +}; + +export default function LocaleLayout({ children, params: { locale } }: LayoutProps) { + if (!ALLOWED_LOCALES.includes(locale as any)) notFound(); + + unstable_setRequestLocale(locale); + + return ( + + + + {children} + + + + ); +}; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index c3dc09c..959699b 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,28 +1,12 @@ import React, { ReactNode } from 'react'; -import { unstable_setRequestLocale } from 'next-intl/server'; -import type { Metadata } from 'next'; import { Comfortaa, Inter } from 'next/font/google'; -import { notFound } from 'next/navigation'; -import { ConfigProvider } from 'antd'; -import StyledRegistry from '../../StyleRegistry'; -import StyledComponentsRegistry from '../../AntdRegistry'; -import { ALLOWED_LOCALES } from '../constants/locale'; -import theme from '../constants/theme'; -import '../../styles/style.scss'; +import '../styles/style.scss'; type RootLayoutProps = { children: ReactNode; params: { locale: string }; }; -export function generateStaticParams() { - return ALLOWED_LOCALES.map((locale) => ({ locale })); -} - -export const metadata: Metadata = { - title: 'Bbuddy' -}; - const comfortaa = Comfortaa({ weight: ['300', '400', '500', '600', '700'], subsets: ['latin', 'cyrillic'], @@ -38,20 +22,10 @@ const inter = Inter({ }); export default function RootLayout({ children, params: { locale } }: RootLayoutProps) { - if (!ALLOWED_LOCALES.includes(locale as any)) notFound(); - - unstable_setRequestLocale(locale); - return ( - - - - {children} - - - + {children} );