112 lines
3.0 KiB
TypeScript
112 lines
3.0 KiB
TypeScript
import { Metadata, Viewport } from 'next'
|
||
|
||
import { Toaster } from 'react-hot-toast'
|
||
import { Analytics } from '@vercel/analytics/react'
|
||
|
||
import '@/app/globals.css'
|
||
import i18nConfig from '@/i18nConfig';
|
||
import { fontMono, fontSans } from '@/lib/fonts'
|
||
import { cn } from '@/lib/utils'
|
||
import { Providers } from '@/components/providers/ui-providers'
|
||
|
||
import { Header } from '@/components/header'
|
||
import { Footer } from '@/components/footer'
|
||
// import { Web3Provider } from '@/components/providers/web3-provider'
|
||
import { descriptionRoot } from '@/lib/metadata'
|
||
|
||
import { Inter } from 'next/font/google';
|
||
import { dir } from 'i18next';
|
||
import { ReactNode } from 'react';
|
||
import TranslationsProvider from '@/components/TranslationsProvider';
|
||
import initTranslations from '../i18n';
|
||
|
||
//import { usePathname } from 'next/navigation'; // Next.js 13+ 内置钩子
|
||
|
||
export const runtime = 'edge' // 'nodejs' (default) | 'edge'
|
||
|
||
|
||
const inter = Inter({ subsets: ['latin'] });
|
||
|
||
export const metadata: Metadata = {
|
||
metadataBase: new URL('https://jellyai.xyz'),
|
||
// title: {
|
||
// default: 'JellyAI',
|
||
// template: `JellyAI`
|
||
// },
|
||
title: {
|
||
template: `%s | JellyAI-一个探索人工智能和区块链的有趣应用`,
|
||
default: `JellyAI`,
|
||
},
|
||
description: `${descriptionRoot("JellyAI")}`,
|
||
|
||
icons: {
|
||
icon: '/favicon.png'
|
||
}
|
||
}
|
||
|
||
export const viewport: Viewport = {
|
||
themeColor: [
|
||
{ media: '(prefers-color-scheme: light)', color: 'white' },
|
||
{ media: '(prefers-color-scheme: dark)', color: 'black' }
|
||
]
|
||
}
|
||
|
||
interface RootLayoutProps {
|
||
children: React.ReactNode
|
||
}
|
||
|
||
export function generateStaticParams() {
|
||
return i18nConfig.locales.map(locale => ({ locale }));
|
||
}
|
||
|
||
// export default function RootLayout({ children }: RootLayoutProps) {
|
||
|
||
const i18nNamespaces = ['common', 'home'];
|
||
|
||
export default async function RootLayout({
|
||
children,
|
||
params: { locale }
|
||
}: {
|
||
children: ReactNode;
|
||
params: { locale: string };
|
||
}) {
|
||
|
||
const { t, resources } = await initTranslations(locale, i18nNamespaces);
|
||
|
||
//const pathname = usePathname(); // 获取当前页面路径
|
||
|
||
// 如果路径是某些特定页面(例如 /auth),则不渲染 Header
|
||
const showHeader = !pathname.startsWith('/auth');
|
||
|
||
return (
|
||
<html lang={locale} dir={dir(locale)} suppressHydrationWarning>
|
||
<head />
|
||
<body
|
||
className={cn(
|
||
inter.className,
|
||
'font-sans antialiased',
|
||
fontSans.variable,
|
||
fontMono.variable
|
||
)}
|
||
>
|
||
<TranslationsProvider
|
||
namespaces={i18nNamespaces}
|
||
locale={locale}
|
||
resources={resources}>
|
||
<Toaster />
|
||
<Providers attribute="class" defaultTheme="system" enableSystem>
|
||
<div className="flex min-h-screen flex-col">
|
||
<main className="flex flex-1 flex-col bg-muted/0.3">
|
||
<Header />
|
||
{children}
|
||
{/* <Footer /> */}
|
||
</main>
|
||
</div>
|
||
{/* <Analytics /> */}
|
||
</Providers>
|
||
</TranslationsProvider>
|
||
</body>
|
||
</html>
|
||
)
|
||
}
|