| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import '../globals.css';
- import { visibleArticles } from '@/lib/blog/data';
- import Navbar from '@/components/Navbar';
- import Footer from '@/components/Footer';
- import { Toaster } from 'react-hot-toast';
- import { LanguageProvider } from '@/lib/i18n/LanguageContext';
- import RetroConfirmDialog from '@/components/common/RetroConfirmDialog';
- import { headers } from 'next/headers';
- import { requestLocale } from '@/lib/i18n/request';
- import { getMessages } from '@/lib/i18n/dictionaries';
- import { formattingLocale } from '@/lib/i18n/config';
- import { isAdminPath } from '@/lib/i18n/routes';
- export default function RootLayout({ children }: { children: React.ReactNode }) {
- const locale = requestLocale();
- const admin = isAdminPath(headers().get('x-strata-path') || '/');
- const messages = admin ? undefined : getMessages(locale);
- return (
- <html lang={formattingLocale(locale)}>
- <body className="bg-slate-50 min-h-screen flex flex-col font-sans">
- <LanguageProvider initialLang={locale} detectPreference={admin} navigateOnLanguageChange={!admin} messages={messages} localizedUI={!admin}>
- {!admin && <a href="#main-content" className="sr-only focus:not-sr-only focus:absolute focus:top-2 focus:left-2 focus:z-[100] focus:bg-amber-300 focus:border-2 focus:border-black focus:p-3">{messages?.['跳到主要内容']}</a>}
- <Navbar showBlog={visibleArticles('en').length > 0} />
-
- <main id="main-content" tabIndex={-1} className={admin ? 'flex-grow' : 'flex-grow min-w-0 [overflow-wrap:anywhere] hyphens-auto'}>
- {children}
- </main>
-
- <Footer />
- <RetroConfirmDialog />
- </LanguageProvider>
-
- <Toaster
- position="top-center"
- reverseOrder={false}
- toastOptions={{
- duration: 3500,
- className: '!border-2 !border-black !bg-neutral-50 !text-black !font-mono !text-xs !shadow-[4px_4px_0px_#000] !rounded-none !px-4 !py-3',
- success: {
- iconTheme: {
- primary: '#000',
- secondary: '#6ee7b7',
- },
- },
- error: {
- iconTheme: {
- primary: '#000',
- secondary: '#fecdd3',
- },
- },
- }}
- />
- </body>
- </html>
- );
- }
|