- Modified the meta collection to include files with 'meta**.json' for improved matching. - Added new translation keys for 'blog' in English and Chinese localization files. - Updated social links in the layout to use the XTwitterIcon for consistency. - Adjusted image paths in the features page for better organization. - Removed unused LocaleSwitcher import from the footer component.
115 lines
3.1 KiB
TypeScript
115 lines
3.1 KiB
TypeScript
import { XTwitterIcon } from '@/components/icons/x';
|
|
import { ModeSwitcher } from '@/components/layout/mode-switcher';
|
|
import { Logo } from '@/components/logo';
|
|
import { websiteConfig } from '@/config';
|
|
import { LOCALE_LIST } from '@/i18n/routing';
|
|
import { docsI18nConfig } from '@/lib/docs/i18n';
|
|
import { source } from '@/lib/docs/source';
|
|
import { I18nProvider, Translations } from 'fumadocs-ui/i18n';
|
|
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
|
|
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
|
|
import { BookIcon, HomeIcon } from 'lucide-react';
|
|
import { Locale } from 'next-intl';
|
|
import { getTranslations } from 'next-intl/server';
|
|
import type { ReactNode } from 'react';
|
|
|
|
import '@/styles/mdx.css';
|
|
|
|
// available languages that will be displayed on UI
|
|
// make sure `locale` is consistent with your i18n config
|
|
const locales = Object.entries(LOCALE_LIST).map(([locale, data]) => ({
|
|
name: data.name,
|
|
locale,
|
|
}));
|
|
|
|
interface DocsLayoutProps {
|
|
children: ReactNode;
|
|
params: Promise<{ locale: Locale }>;
|
|
}
|
|
|
|
/**
|
|
* 1. Configure navigation
|
|
* https://fumadocs.vercel.app/docs/ui/navigation/links
|
|
* https://fumadocs.vercel.app/docs/ui/navigation/sidebar
|
|
*
|
|
* example:
|
|
* https://github.com/fuma-nama/fumadocs/blob/dev/apps/docs/app/layout.config.tsx
|
|
*
|
|
* 2. Organizing Pages
|
|
* https://fumadocs.vercel.app/docs/ui/page-conventions
|
|
*
|
|
* example:
|
|
* https://github.com/fuma-nama/fumadocs/blob/dev/apps/docs/content/docs/ui/meta.json
|
|
*/
|
|
export default async function DocsRootLayout({ children, params }: DocsLayoutProps) {
|
|
const { locale } = await params;
|
|
const t = await getTranslations({ locale, namespace: 'DocsPage' });
|
|
|
|
// Create translations object for fumadocs-ui from our message files
|
|
const translations: Partial<Translations> = {
|
|
toc: t('toc'),
|
|
search: t('search'),
|
|
lastUpdate: t('lastUpdate'),
|
|
searchNoResult: t('searchNoResult'),
|
|
previousPage: t('previousPage'),
|
|
nextPage: t('nextPage'),
|
|
chooseLanguage: t('chooseLanguage'),
|
|
};
|
|
|
|
// Docs layout configurations
|
|
const docsOptions: BaseLayoutProps = {
|
|
i18n: docsI18nConfig,
|
|
githubUrl: websiteConfig.social.github ?? undefined,
|
|
nav: {
|
|
title: (
|
|
<>
|
|
<Logo className="size-6" />
|
|
{t('title')}
|
|
</>
|
|
),
|
|
},
|
|
links: [
|
|
{
|
|
text: t('homepage'),
|
|
url: '/',
|
|
icon: <HomeIcon />,
|
|
active: 'none',
|
|
},
|
|
{
|
|
text: t('blog'),
|
|
url: '/blog',
|
|
icon: <BookIcon />,
|
|
active: 'none',
|
|
},
|
|
...(websiteConfig.social.twitter
|
|
? [
|
|
{
|
|
type: "icon" as const,
|
|
icon: <XTwitterIcon />,
|
|
text: "X",
|
|
url: websiteConfig.social.twitter,
|
|
secondary: true,
|
|
}
|
|
]
|
|
: [])
|
|
],
|
|
themeSwitch: {
|
|
enabled: true,
|
|
mode: 'light-dark-system',
|
|
component: <ModeSwitcher />
|
|
},
|
|
};
|
|
|
|
return (
|
|
<I18nProvider
|
|
locales={locales}
|
|
locale={locale}
|
|
translations={translations}
|
|
>
|
|
<DocsLayout tree={source.pageTree[locale]} {...docsOptions}>
|
|
{children}
|
|
</DocsLayout>
|
|
</I18nProvider>
|
|
);
|
|
}
|