mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-09 06:55:07 +00:00
134 lines
3.9 KiB
TypeScript
134 lines
3.9 KiB
TypeScript
import "@/styles/globals.css"
|
|
import { Metadata, Viewport } from "next"
|
|
import Link from "next/link"
|
|
import { ArrowRightIcon } from "lucide-react"
|
|
|
|
import { META_THEME_COLORS, siteConfig } from "@/config/site"
|
|
import { fontMono, fontSans } from "@/lib/fonts"
|
|
import { cn } from "@/lib/utils"
|
|
import { Analytics } from "@/components/analytics"
|
|
import { ThemeProvider } from "@/components/providers"
|
|
import { TailwindIndicator } from "@/components/tailwind-indicator"
|
|
import { ThemeSwitcher } from "@/components/theme-switcher"
|
|
import { Toaster as DefaultToaster } from "@/registry/default/ui/toaster"
|
|
import { Toaster as NewYorkSonner } from "@/registry/new-york/ui/sonner"
|
|
import { Toaster as NewYorkToaster } from "@/registry/new-york/ui/toaster"
|
|
|
|
export const metadata: Metadata = {
|
|
title: {
|
|
default: siteConfig.name,
|
|
template: `%s - ${siteConfig.name}`,
|
|
},
|
|
metadataBase: new URL(siteConfig.url),
|
|
description: siteConfig.description,
|
|
keywords: [
|
|
"Next.js",
|
|
"React",
|
|
"Tailwind CSS",
|
|
"Server Components",
|
|
"Radix UI",
|
|
],
|
|
authors: [
|
|
{
|
|
name: "shadcn",
|
|
url: "https://shadcn.com",
|
|
},
|
|
],
|
|
creator: "shadcn",
|
|
openGraph: {
|
|
type: "website",
|
|
locale: "en_US",
|
|
url: siteConfig.url,
|
|
title: siteConfig.name,
|
|
description: siteConfig.description,
|
|
siteName: siteConfig.name,
|
|
images: [
|
|
{
|
|
url: siteConfig.ogImage,
|
|
width: 1200,
|
|
height: 630,
|
|
alt: siteConfig.name,
|
|
},
|
|
],
|
|
},
|
|
twitter: {
|
|
card: "summary_large_image",
|
|
title: siteConfig.name,
|
|
description: siteConfig.description,
|
|
images: [siteConfig.ogImage],
|
|
creator: "@shadcn",
|
|
},
|
|
icons: {
|
|
icon: "/favicon.ico",
|
|
shortcut: "/favicon-16x16.png",
|
|
apple: "/apple-touch-icon.png",
|
|
},
|
|
manifest: `${siteConfig.url}/site.webmanifest`,
|
|
}
|
|
|
|
export const viewport: Viewport = {
|
|
themeColor: META_THEME_COLORS.light,
|
|
}
|
|
|
|
interface RootLayoutProps {
|
|
children: React.ReactNode
|
|
}
|
|
|
|
export default function RootLayout({ children }: RootLayoutProps) {
|
|
return (
|
|
<>
|
|
<html lang="en" suppressHydrationWarning>
|
|
<head>
|
|
<script
|
|
dangerouslySetInnerHTML={{
|
|
__html: `
|
|
try {
|
|
if (localStorage.theme === 'dark' || ((!('theme' in localStorage) || localStorage.theme === 'system') && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
|
document.querySelector('meta[name="theme-color"]').setAttribute('content', '${META_THEME_COLORS.dark}')
|
|
}
|
|
} catch (_) {}
|
|
`,
|
|
}}
|
|
/>
|
|
</head>
|
|
<body
|
|
className={cn(
|
|
"bg-background min-h-svh font-sans antialiased",
|
|
fontSans.variable,
|
|
fontMono.variable
|
|
)}
|
|
>
|
|
<ThemeProvider
|
|
attribute="class"
|
|
defaultTheme="system"
|
|
enableSystem
|
|
disableTransitionOnChange
|
|
enableColorScheme
|
|
>
|
|
<div vaul-drawer-wrapper="">
|
|
<div className="bg-background relative flex min-h-svh flex-col">
|
|
<div className="bg-muted text-muted-foreground sticky top-0 z-[100] flex h-10 items-center justify-center gap-2 px-4 text-sm">
|
|
You are viewing the v3 docs.{" "}
|
|
<Link
|
|
href="https://ui.shadcn.com"
|
|
className="text-primary flex items-center gap-1 underline"
|
|
>
|
|
Switch to latest <ArrowRightIcon className="size-3" />
|
|
</Link>
|
|
</div>
|
|
{children}
|
|
</div>
|
|
</div>
|
|
<TailwindIndicator />
|
|
<ThemeSwitcher />
|
|
<Analytics />
|
|
<NewYorkToaster />
|
|
<DefaultToaster />
|
|
<NewYorkSonner />
|
|
</ThemeProvider>
|
|
</body>
|
|
</html>
|
|
</>
|
|
)
|
|
}
|