Files

150 lines
4.4 KiB
TypeScript

import "@/styles/globals.css"
import { Metadata, Viewport } from "next"
import { siteConfig } from "@/config/site"
import { fontMono, fontSans } from "@/lib/fonts"
import { cn } from "@/lib/utils"
import { ActiveThemeProvider } from "@/components/active-theme"
import { Analytics } from "@/components/analytics"
import { ThemeProvider } from "@/components/providers"
import { SkipLinks } from "@/components/skip-links"
import { TailwindIndicator } from "@/components/tailwind-indicator"
import { ThemeSwitcher } from "@/components/theme-switcher"
import { Web3Provider } from "@/components/web3-provider"
import { Toaster as NewYorkSonner } from "@/registry/default/ui/sonner"
import {
Toaster as DefaultToaster,
Toaster as NewYorkToaster,
} from "@/registry/default/ui/toaster"
/**
* The registry document — html, body and every provider the registry surfaces
* need. It is a COMPONENT rather than the app's one root layout because the
* site now serves two substrates: this one (Radix + Tailwind, which is what the
* registry ships to customers) and `@hanzo/ui` v8 on `@hanzo/gui`, which brings
* its own root and must not inherit Tailwind's body.
*
* Next allows exactly one root layout per route group, so each group that wants
* this shell calls it here instead of holding a copy of it.
*/
const META_THEME_COLORS = {
light: "white",
dark: "black",
}
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: "hanzo",
url: "https://hanzo.ai",
},
],
creator: "hanzo",
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: "@hanzoai",
},
icons: {
icon: [
{ url: "/icon.png", sizes: "32x32", type: "image/png" },
{ url: "/favicon-16x16.png", sizes: "16x16", type: "image/png" },
{ url: "/favicon-32x32.png", sizes: "32x32", type: "image/png" },
],
apple: { url: "/apple-icon.png", sizes: "512x512", type: "image/png" },
},
manifest: `${siteConfig.url}/site.webmanifest`,
}
export const viewport: Viewport = {
themeColor: [
{ media: "(prefers-color-scheme: light)", color: "white" },
{ media: "(prefers-color-scheme: dark)", color: "black" },
],
}
export function Document({ children }: { children: React.ReactNode }) {
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(
"min-h-svh bg-background font-sans antialiased",
fontSans.variable,
fontMono.variable
)}
>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
enableColorScheme
>
<Web3Provider>
<ActiveThemeProvider initialTheme="neutral">
<SkipLinks />
<div vaul-drawer-wrapper="">
<div className="relative flex min-h-svh flex-col bg-background">
{children}
</div>
</div>
<TailwindIndicator />
<ThemeSwitcher />
<Analytics />
<NewYorkToaster />
<DefaultToaster />
<NewYorkSonner />
</ActiveThemeProvider>
</Web3Provider>
</ThemeProvider>
</body>
</html>
)
}