fix root layout

This commit is contained in:
Сюткина Дарья Александровна (4047910) 2023-12-29 18:24:56 +04:00
parent ae92749597
commit e14421ccc0
4 changed files with 44 additions and 29 deletions

3
.gitignore vendored
View File

@ -16,6 +16,9 @@
# production # production
/build /build
# ide
/.idea
# misc # misc
.DS_Store .DS_Store
*.pem *.pem

View File

@ -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, children: ReactNode,
news: ReactNode, news: ReactNode,
directions: ReactNode, directions: ReactNode,

View File

@ -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 (
<StyledRegistry>
<StyledComponentsRegistry>
<ConfigProvider theme={theme}>
{children}
</ConfigProvider>
</StyledComponentsRegistry>
</StyledRegistry>
);
};

View File

@ -1,28 +1,12 @@
import React, { ReactNode } from 'react'; 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 { Comfortaa, Inter } from 'next/font/google';
import { notFound } from 'next/navigation'; import '../styles/style.scss';
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';
type RootLayoutProps = { type RootLayoutProps = {
children: ReactNode; children: ReactNode;
params: { locale: string }; params: { locale: string };
}; };
export function generateStaticParams() {
return ALLOWED_LOCALES.map((locale) => ({ locale }));
}
export const metadata: Metadata = {
title: 'Bbuddy'
};
const comfortaa = Comfortaa({ const comfortaa = Comfortaa({
weight: ['300', '400', '500', '600', '700'], weight: ['300', '400', '500', '600', '700'],
subsets: ['latin', 'cyrillic'], subsets: ['latin', 'cyrillic'],
@ -38,20 +22,10 @@ const inter = Inter({
}); });
export default function RootLayout({ children, params: { locale } }: RootLayoutProps) { export default function RootLayout({ children, params: { locale } }: RootLayoutProps) {
if (!ALLOWED_LOCALES.includes(locale as any)) notFound();
unstable_setRequestLocale(locale);
return ( return (
<html lang={locale} className={`${comfortaa.variable} ${inter.variable}`}> <html lang={locale} className={`${comfortaa.variable} ${inter.variable}`}>
<body> <body>
<StyledRegistry>
<StyledComponentsRegistry>
<ConfigProvider theme={theme}>
{children} {children}
</ConfigProvider>
</StyledComponentsRegistry>
</StyledRegistry>
</body> </body>
</html> </html>
); );