refactor: move docs RootProvider to LocaleLayout Providers
This commit is contained in:
parent
5b7dae6586
commit
584d3faa1a
@ -1,35 +0,0 @@
|
||||
import { ModeSwitcher } from '@/components/layout/mode-switcher';
|
||||
import { Logo } from '@/components/logo';
|
||||
import { websiteConfig } from '@/config';
|
||||
import { defaultMessages } from '@/i18n/messages';
|
||||
import { docsI18nConfig } from '@/lib/docs/i18n';
|
||||
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
|
||||
|
||||
/**
|
||||
* Docs layout configurations
|
||||
* https://fumadocs.vercel.app/docs/ui/layouts/docs
|
||||
*/
|
||||
export const baseOptions: BaseLayoutProps = {
|
||||
i18n: docsI18nConfig,
|
||||
githubUrl: websiteConfig.social.github ?? undefined,
|
||||
nav: {
|
||||
title: (
|
||||
<>
|
||||
<Logo className="size-6" />
|
||||
{defaultMessages.Metadata.name}
|
||||
</>
|
||||
),
|
||||
},
|
||||
links: [
|
||||
{
|
||||
text: 'Homepage',
|
||||
url: '/',
|
||||
active: 'nested-url',
|
||||
}
|
||||
],
|
||||
themeSwitch: {
|
||||
enabled: true,
|
||||
mode: 'light-dark-system',
|
||||
component: <ModeSwitcher />
|
||||
},
|
||||
};
|
@ -67,7 +67,7 @@ export default async function DocsRootLayout({ children, params }: DocsLayoutPro
|
||||
};
|
||||
|
||||
return (
|
||||
<DocsProviders>
|
||||
// <DocsProviders>
|
||||
<I18nProvider
|
||||
locales={locales}
|
||||
locale={locale}
|
||||
@ -77,6 +77,6 @@ export default async function DocsRootLayout({ children, params }: DocsLayoutPro
|
||||
{children}
|
||||
</DocsLayout>
|
||||
</I18nProvider>
|
||||
</DocsProviders>
|
||||
// </DocsProviders>
|
||||
);
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { RootProvider } from 'fumadocs-ui/provider';
|
||||
import { useTheme } from 'next-themes';
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
interface DocsProvidersProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
/***
|
||||
* Docs Configuration
|
||||
*
|
||||
* https://fumadocs.vercel.app/docs/ui/theme#lightdark-modes
|
||||
*/
|
||||
export function DocsProviders({ children }: DocsProvidersProps) {
|
||||
const theme = useTheme();
|
||||
|
||||
return (
|
||||
<RootProvider theme={theme}>
|
||||
{children}
|
||||
</RootProvider>
|
||||
);
|
||||
}
|
@ -1,12 +1,15 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { ThemeProvider } from 'next-themes';
|
||||
import { ThemeProvider, useTheme } from 'next-themes';
|
||||
import { TooltipProvider } from '@/components/ui/tooltip';
|
||||
import { PropsWithChildren } from 'react';
|
||||
import { ActiveThemeProvider } from '@/components/layout/active-theme';
|
||||
import { RootProvider } from 'fumadocs-ui/provider';
|
||||
|
||||
export function Providers({ children }: PropsWithChildren) {
|
||||
const theme = useTheme();
|
||||
|
||||
return (
|
||||
<ThemeProvider
|
||||
attribute="class"
|
||||
@ -15,7 +18,9 @@ export function Providers({ children }: PropsWithChildren) {
|
||||
disableTransitionOnChange
|
||||
>
|
||||
<ActiveThemeProvider>
|
||||
<TooltipProvider>{children}</TooltipProvider>
|
||||
<RootProvider theme={theme}>
|
||||
<TooltipProvider>{children}</TooltipProvider>
|
||||
</RootProvider>
|
||||
</ActiveThemeProvider>
|
||||
</ThemeProvider>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user