Skip to content

Commit

Permalink
fix(modern-plugin): support auto sidebar when is bilingual
Browse files Browse the repository at this point in the history
  • Loading branch information
10Derozan committed Dec 5, 2023
1 parent a96e651 commit ae2f76d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-tools-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@modern-js/plugin-rspress': patch
---

fix(modern-plugin): support auto sidebar when is bilingual
27 changes: 18 additions & 9 deletions packages/modern-plugin-rspress/src/features/lanchDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserConfig>(
Expand Down

0 comments on commit ae2f76d

Please sign in to comment.