Files
3x-ui/docs/lib/layout.shared.tsx
Sanaei cb902314db fix(docs): restore theme switch without runtime warnings
Move html/body shell and global css to root app layout to avoid hydration/script warnings from nested document nodes. Disable provider theme injection and add a custom script-free theme switch in shared layout slots.

Also migrate docs search static client initializer to ZBSearch (initDB), add zbsearch dependency, and align docs lint tooling with ESLint 9 compatibility so npm run lint passes.
2026-08-06 17:59:23 +02:00

71 lines
2.0 KiB
TypeScript

import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
import { Heart } from 'lucide-react';
import { Logo } from '@/components/logo';
import { TelegramIcon } from '@/components/icons';
import { DocsThemeSwitch } from '@/components/theme-switch';
import { appName, productRepoUrl, telegramChannel, telegramChannelUrl, donateUrl, siteUrl } from './shared';
import { getSiteMessages } from './site-i18n';
// Build locale-aware shared layout options. With `hideLocale: 'default-locale'`,
// English URLs have no prefix while other locales are prefixed (`/fa`, `/ru`, `/zh`).
export function baseOptions(lang: string): BaseLayoutProps {
const prefix = lang === 'en' ? '' : `/${lang}`;
const m = getSiteMessages(lang);
return {
slots: {
themeSwitch: DocsThemeSwitch,
},
nav: {
title: (
<span className="inline-flex items-center gap-2 font-semibold">
<Logo className="h-6" />
{appName}
</span>
),
url: `${prefix}/`,
},
githubUrl: productRepoUrl,
links: [
{
text: m.documentation,
url: `${prefix}/docs`,
active: 'nested-url',
},
// Live component workbench built from frontend/ and published alongside the docs.
{
text: 'Storybook',
url: `${siteUrl}/storybook/`,
external: true,
},
{
type: 'icon',
label: `Telegram channel (@${telegramChannel})`,
icon: <TelegramIcon />,
text: 'Telegram',
url: telegramChannelUrl,
external: true,
},
// Compact heart icon in the top nav bars (home + docs).
{
type: 'icon',
on: 'nav',
label: m.donate,
icon: <Heart />,
text: m.donate,
url: donateUrl,
external: true,
},
// Prominent labelled entry in the docs sidebar / mobile menu.
{
type: 'main',
on: 'menu',
icon: <Heart />,
text: m.donate,
url: donateUrl,
external: true,
},
],
};
}