forked from MarsX-dev/devhunt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayout.tsx
127 lines (116 loc) · 4.2 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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import Navbar from '@/components/ui/Navbar';
import './globals.css';
import './prismjs-theme.css';
import { Inter } from 'next/font/google';
import Script from 'next/script';
import SupabaseListener from '@/components/supabase/listener';
import SupabaseProvider from '@/components/supabase/provider';
import { createServerClient } from '@/utils/supabase/server';
import type { Database, Profile } from '@/utils/supabase/types';
import type { SupabaseClient } from '@supabase/auth-helpers-nextjs';
import Footer from '@/components/ui/Footer/Footer';
import ProfileService from '@/utils/supabase/services/profile';
import Banner from '@/components/ui/Banner';
import ProgressBarClient from '@/components/ui/ProgressBarClient';
import ModalBannerCodeClient from '@/components/ui/ModalBannerCode/ModalBannerCodeClient';
import dynamic from 'next/dynamic';
const ChatWindow = dynamic(() => import('@/components/ui/ChatWindow'), { ssr: false });
export type TypedSupabaseClient = SupabaseClient<Database>;
declare global {
interface Window {
usermavenQ: any; // Replace 'any' with the appropriate type of 'usermavenQ'
}
}
const { title, description, ogImage } = {
title: 'Dev Hunt – The best new Dev Tools every day.',
description: 'A launchpad for dev tools, built by developers for developers, open source, and fair.',
ogImage: 'https://devhunt.org/devhuntog.png?v=2',
};
export const metadata = {
title,
description,
metadataBase: new URL('https://devhunt.org'),
openGraph: {
title,
description,
images: [ogImage],
url: 'https://devhunt.org',
},
twitter: {
card: 'summary_large_image',
title,
description,
images: [ogImage],
},
};
const inter = Inter({ subsets: ['latin'] });
// do not cache this layout
export const revalidate = 0;
export default async function RootLayout({ children }: { children: React.ReactNode }) {
const supabase = createServerClient();
const {
data: { session },
} = await supabase.auth.getSession();
const user = session?.user;
const profileService = new ProfileService(createServerClient());
const profile = user ? await profileService.getById(user?.id) : null;
return (
<html lang="en" className="bg-slate-900">
<head>
{process.env.USER_MAVEN_KEY && (
<>
<Script
strategy="afterInteractive"
src="https://t.usermaven.com/lib.js"
data-key={process.env.USER_MAVEN_KEY}
data-tracking-host="https://events.usermaven.com"
data-autocapture="true"
data-privacy-policy="strict"
defer
></Script>
<Script
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `
window.usermaven = window.usermaven || (function()
{(window.usermavenQ = window.usermavenQ || []).push(arguments)})
`,
}}
/>
<Script
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "ic87ytbm3p");
`,
}}
/>
</>
)}
<meta httpEquiv="Content-Language" content="en" />
<meta property="og:locale" content="en_US" />
<meta name="language" content="English" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0" />
</head>
<body className={inter.className}>
<main>
<ChatWindow />
<SupabaseProvider user={profile as Profile} session={session}>
<SupabaseListener serverAccessToken={session?.access_token} />
<Banner />
<Navbar />
<ModalBannerCodeClient />
{children}
{/* <ProgressBarClient /> */}
<Footer />
</SupabaseProvider>
</main>
</body>
</html>
);
}