2022-11-09 21:38:05 -05:00
|
|
|
import "@styles/globals.css"
|
|
|
|
import { LayoutWrapper } from "./root-layout-wrapper"
|
2022-11-15 23:50:54 -05:00
|
|
|
import styles from "@styles/Home.module.css"
|
|
|
|
import { getSession } from "@lib/server/session"
|
|
|
|
import ThemeProvider from "@components/theme/ThemeProvider"
|
|
|
|
import { THEME_COOKIE_NAME } from "@components/theme/theme"
|
|
|
|
import { useServerTheme } from "@components/theme/ThemeServerContextProvider"
|
2022-11-09 01:14:43 -05:00
|
|
|
|
|
|
|
interface RootLayoutProps {
|
|
|
|
children: React.ReactNode
|
|
|
|
}
|
|
|
|
|
2022-11-15 23:50:54 -05:00
|
|
|
export default async function RootLayout({ children }: RootLayoutProps) {
|
2022-11-14 02:02:31 -05:00
|
|
|
// TODO: this opts out of SSG
|
2022-11-14 04:28:40 -05:00
|
|
|
const session = await getSession()
|
2022-11-09 01:14:43 -05:00
|
|
|
return (
|
2022-11-15 23:50:54 -05:00
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<script
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: `
|
|
|
|
(function() {
|
|
|
|
var theme = document.cookie
|
|
|
|
.split('; ')
|
|
|
|
.find(row => row.startsWith('${THEME_COOKIE_NAME}='))
|
|
|
|
.split('=')[1];
|
|
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
|
|
})();
|
2022-11-18 01:36:53 -05:00
|
|
|
`
|
2022-11-15 23:50:54 -05:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</head>
|
|
|
|
<ThemeProvider>
|
2022-11-11 22:17:44 -05:00
|
|
|
<body className={styles.main}>
|
2022-11-15 23:50:54 -05:00
|
|
|
<LayoutWrapper
|
|
|
|
signedIn={Boolean(session?.user)}
|
|
|
|
isAdmin={session?.user.role === "admin"}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</LayoutWrapper>
|
2022-11-10 02:11:36 -05:00
|
|
|
</body>
|
2022-11-15 23:50:54 -05:00
|
|
|
</ThemeProvider>
|
|
|
|
</html>
|
2022-11-09 01:14:43 -05:00
|
|
|
)
|
|
|
|
}
|