Moved to next js ssr (with fixes)
This commit is contained in:
+7
-2
@@ -1,4 +1,5 @@
|
||||
import type { Metadata, Viewport } from 'next';
|
||||
import { cookies } from 'next/headers';
|
||||
import '@/src/index.css';
|
||||
import '@/src/App.css';
|
||||
import '@/src/css/Unit.css';
|
||||
@@ -49,8 +50,12 @@ export default function RootLayout({
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
// Читаем тему из cookie на сервере, чтобы сразу отрендерить нужную тему без мерцания.
|
||||
const themeCookie = cookies().get('theme')?.value;
|
||||
const initialMode = themeCookie === 'light' ? 'light' : 'dark';
|
||||
|
||||
return (
|
||||
<html lang="en">
|
||||
<html lang="en" data-theme={initialMode} style={{ colorScheme: initialMode }}>
|
||||
<body>
|
||||
{/* Yandex.Metrika */}
|
||||
<script
|
||||
@@ -69,7 +74,7 @@ export default function RootLayout({
|
||||
/>
|
||||
</div>
|
||||
</noscript>
|
||||
<ThemeProvider>
|
||||
<ThemeProvider initialMode={initialMode}>
|
||||
<AppShell>{children}</AppShell>
|
||||
</ThemeProvider>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user