mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
CLI: support Next.js 15 i18n auto-config
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@fumadocs/cli': patch
|
||||
---
|
||||
|
||||
support Next.js 15 i18n auto-config
|
||||
@@ -46,7 +46,7 @@ export function runTransform(sourceFile: SourceFile): void {
|
||||
.join('\n');
|
||||
|
||||
parent.setBodyText(
|
||||
`<I18nProvider locale={params.lang} locales={[
|
||||
`<I18nProvider locale={(await params).lang} locales={[
|
||||
{ locale: 'en', name: 'English' }
|
||||
]}>
|
||||
${inner.trim()}
|
||||
@@ -64,8 +64,10 @@ export function runTransform(sourceFile: SourceFile): void {
|
||||
const func = sourceFile
|
||||
.getDescendantsOfKind(SyntaxKind.FunctionDeclaration)
|
||||
.find((v) => v.isDefaultExport());
|
||||
func?.toggleModifier('async', true);
|
||||
|
||||
const param = func?.getParameters().at(0);
|
||||
param?.setType(`{ params: { lang: string }, children: ReactNode }`);
|
||||
param?.setType(`{ params: Promise<{ lang: string }>, children: ReactNode }`);
|
||||
param?.set({
|
||||
name: `{ params, children }`,
|
||||
});
|
||||
|
||||
@@ -8,11 +8,11 @@ const inter = Inter({
|
||||
subsets: ['latin'],
|
||||
});
|
||||
|
||||
export default function Layout({ params, children }: { params: { lang: string }, children: ReactNode }) {
|
||||
export default async function Layout({ params, children }: { params: Promise<{ lang: string }>, children: ReactNode }) {
|
||||
return (
|
||||
<html lang="en" className={inter.className} suppressHydrationWarning>
|
||||
<body>
|
||||
<I18nProvider locale={params.lang} locales={[
|
||||
<I18nProvider locale={(await params).lang} locales={[
|
||||
{ locale: 'en', name: 'English' }
|
||||
]}>
|
||||
<RootProvider>{children}</RootProvider>
|
||||
|
||||
Reference in New Issue
Block a user