diff --git a/.changeset/neat-tools-give.md b/.changeset/neat-tools-give.md new file mode 100644 index 000000000..fa5102b46 --- /dev/null +++ b/.changeset/neat-tools-give.md @@ -0,0 +1,5 @@ +--- +'@modern-js/plugin-rspress': patch +--- + +fix(modern-plugin): support auto sidebar when is bilingual diff --git a/packages/modern-plugin-rspress/src/features/lanchDoc.ts b/packages/modern-plugin-rspress/src/features/lanchDoc.ts index 0c2935481..da3255674 100644 --- a/packages/modern-plugin-rspress/src/features/lanchDoc.ts +++ b/packages/modern-plugin-rspress/src/features/lanchDoc.ts @@ -98,16 +98,25 @@ export async function launchDoc({ return [...fileItems, ...directoryItems]; }; - return { - '': [ - { - text: 'Module List', - link: `/index`, - collapsible: false, - items: await traverse(base), - }, - ], + + const sidebarGroup = [ + { + text: 'Module List', + link: `/index`, + collapsible: false, + items: await traverse(base), + }, + ]; + const sidebar: Sidebar = { + '/': sidebarGroup, }; + + // support auto sidebar when is bilingual + if (languages.length === 2) { + const path = `/${languages[1]}/`; + sidebar[path] = sidebarGroup; + } + return sidebar; }; const modernDocConfig = mergeModuleDocConfig(