-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathlayout.tsx
More file actions
91 lines (85 loc) · 2.38 KB
/
layout.tsx
File metadata and controls
91 lines (85 loc) · 2.38 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
import "../globals.css";
import type { Metadata } from "next";
import { Nunito, Inter } from "next/font/google";
import { cn } from "@/lib/utils";
import { ThemeProvider } from "@/components/theme-provider";
import { AppSidebar } from "@/components/app-sidebar";
import { SiteHeader } from "@/components/site-header";
import { SidebarProvider, SidebarInset } from "@/components/ui/sidebar";
import { Toaster } from "@/components/ui/sonner";
import { SiteAnalytics } from "@/components/analytics";
const nunito = Nunito({
subsets: ["latin"],
display: "swap",
variable: "--font-nunito",
});
const inter = Inter({
subsets: ["latin"],
display: "swap",
variable: "--font-inter",
});
export const metadata: Metadata = {
title: {
template: "%s | CodingCat.dev Dashboard",
default: "Content Ops Dashboard | CodingCat.dev",
},
description: "Manage your automated content engine",
};
export default async function DashboardLayout({
children,
}: {
children: React.ReactNode;
}) {
// Try to get user — if Supabase isn't configured or user isn't logged in,
// the proxy will have already redirected to login for protected routes.
// The login page itself renders without the sidebar chrome.
let user = null;
try {
const supabaseUrl =
process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL;
const supabaseAnonKey =
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || process.env.SUPABASE_ANON_KEY;
if (supabaseUrl && supabaseAnonKey) {
const { createClient } = await import("@/lib/supabase/server");
const supabase = await createClient();
const { data } = await supabase.auth.getUser();
user = data?.user ?? null;
}
} catch {
// Supabase not available — continue without user
}
return (
<html lang="en" suppressHydrationWarning>
<body
className={cn(
"min-h-screen bg-background font-sans antialiased",
nunito.variable,
inter.variable,
)}
>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
{user ? (
<SidebarProvider>
<AppSidebar user={user} />
<SidebarInset>
<SiteHeader />
<main className="flex flex-1 flex-col gap-4 p-4 md:p-6">
{children}
</main>
</SidebarInset>
</SidebarProvider>
) : (
<>{children}</>
)}
<Toaster />
</ThemeProvider>
<SiteAnalytics />
</body>
</html>
);
}