forked from codu-code/codu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayout.tsx
More file actions
93 lines (86 loc) · 2.58 KB
/
layout.tsx
File metadata and controls
93 lines (86 loc) · 2.58 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { headers } from "next/headers";
import ThemeProvider from "@/components/Theme/ThemeProvider";
import { TRPCReactProvider } from "@/server/trpc/react";
import Footer from "@/components/Footer/Footer";
import Nav from "@/components/Nav/Nav";
import { getServerAuthSession } from "@/server/auth";
import AuthProvider from "@/context/AuthProvider";
import ProgressBar from "@/components/ProgressBar/ProgressBar";
import React from "react";
import { PromptProvider } from "@/components/PromptService";
import { db } from "@/server/db";
import { eq } from "drizzle-orm";
import { user } from "@/server/db/schema";
export const metadata = {
title: "Codú - Join Our Web Developer Community",
description:
"Connect with fellow web developers, learn new skills, and grow together in the supportive Codú community. Sign up now for free!",
icons: [{ rel: "icon", url: "/favicon.ico" }],
publisher: "Codú",
applicationName: "Codú",
keywords: [
"programming",
"frontend",
"community",
"learn",
"programmer",
"article",
"Python",
"JavaScript",
"AWS",
"HTML",
"CSS",
"Tailwind",
"React",
"Angular",
"backend",
],
metadataBase: new URL("https://www.codu.co"),
openGraph: {
images: "/images/og/home-og.png",
},
};
const ALGOLIA_APP_ID = process.env.ALGOLIA_APP_ID || "";
const ALGOLIA_SEARCH_API = process.env.ALGOLIA_SEARCH_API || "";
const ALGOLIA_SOURCE_IDX = process.env.ALGOLIA_SOURCE_IDX || "";
if (!ALGOLIA_APP_ID || !ALGOLIA_SEARCH_API) {
console.error(
".env values required for Algolia search (ALGOLIA_APP_ID and ALGOLIA_SEARCH_API). Visit https://www.algolia.com/ to create a free account and get your API keys.",
);
}
if (!ALGOLIA_SOURCE_IDX) {
console.error(
".env value required for Algolia source ID (ALGOLIA_SOURCE_IDX). Create an index in your Algolia account and set the value to the index name.",
);
}
const algoliaSearchConfig = {
ALGOLIA_APP_ID,
ALGOLIA_SEARCH_API,
ALGOLIA_SOURCE_IDX,
};
export default async function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
const session = await getServerAuthSession();
const userData = session?.user?.id
? await db.query.user.findFirst({
where: eq(user.id, session.user.id),
columns: { username: true },
})
: null;
return (
<>
<div className="grid min-h-screen grid-rows-[auto_1fr_auto]">
<Nav
session={session}
algoliaSearchConfig={algoliaSearchConfig}
username={userData?.username || null}
/>
{children}
<Footer />
</div>
</>
);
}