-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlayout.tsx
48 lines (43 loc) · 1.34 KB
/
layout.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import "../tailwind.css";
import AccountModal from "../components/AccountModal";
import { SessionProvider } from "../components/SessionProvider";
import TopBorder from "../components/TopBorder";
import { Toasts, ToastsProvider } from "../components/Toasts";
import { cookies } from "next/headers";
import { getUser, sessionTokenCookieName } from "../lib/getUser";
export const metadata = {
title: {
template: "%s | Leopard",
default: "Leopard",
},
description: "Convert Scratch projects to JavaScript",
};
/*
Almost all pages in this app are server rendered, so we're okay with making the root
layout server rendered as well. This removes the possibility of having purely static
pages, but that's an acceptable tradeoff.
*/
export default async function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
// Let's fetch the user session data on the server so that it's available immediately
// on the first page load.
const token = cookies().get(sessionTokenCookieName)?.value;
const user = await getUser(token);
return (
<html lang="en">
<body>
<SessionProvider serverUser={user}>
<ToastsProvider>
<AccountModal>
{children}
<Toasts />
</AccountModal>
</ToastsProvider>
</SessionProvider>
</body>
</html>
);
}