suna/frontend/src/app/layout.tsx

62 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-03-30 14:48:57 +08:00
'use client';
import './globals.css';
import { Inter } from 'next/font/google';
import { AuthProvider } from '@/context/auth-context';
import { Toaster } from 'sonner';
2025-03-31 11:41:24 +08:00
import { usePathname } from 'next/navigation';
import { MainNav } from '@/components/main-nav';
import { AppSidebar } from "@/components/app-sidebar"
import { SiteHeader } from "@/components/site-header"
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar"
2025-03-30 14:48:57 +08:00
const inter = Inter({ subsets: ['latin'] });
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
2025-03-31 11:41:24 +08:00
const pathname = usePathname();
// Check if current path is in dashboard routes
const isDashboardRoute = pathname.startsWith('/dashboard') ||
pathname.startsWith('/projects');
// Only show MainNav on marketing pages, not in dashboard routes
const showMainNav = !isDashboardRoute;
2025-03-30 14:48:57 +08:00
2025-03-31 11:41:24 +08:00
// Render dashboard layout or regular layout based on route
const renderContent = () => {
if (isDashboardRoute) {
return (
<SidebarProvider>
<AppSidebar variant="inset" />
<SidebarInset>
2025-03-31 14:33:12 +08:00
<SiteHeader />
2025-03-31 11:41:24 +08:00
{children}
</SidebarInset>
</SidebarProvider>
);
2025-03-30 14:48:57 +08:00
}
2025-03-31 11:41:24 +08:00
return (
<>
{showMainNav && <MainNav />}
2025-03-31 14:33:12 +08:00
{children}
2025-03-31 11:41:24 +08:00
</>
);
};
2025-03-30 14:48:57 +08:00
return (
2025-03-31 06:55:26 +08:00
<html lang="en" className="h-full">
2025-03-31 11:41:24 +08:00
<body className={`${inter.className} h-full overflow-hidden`}>
2025-03-30 14:48:57 +08:00
<AuthProvider>
2025-03-31 14:33:12 +08:00
{renderContent()}
2025-03-30 14:48:57 +08:00
<Toaster position="top-right" />
</AuthProvider>
</body>
</html>
);
}