Feature Request: MultiSidebar support
Closed this issue ยท 7 comments
Hi, thanks for your work!
I hope this tool could also support multisidebar.
currently I tried this:
sidebar: {
'/article/': [],
'/excerpt/': [],
'/idea/': generateSidebar({
root: '/src/idea/',
collapseDepth: 2,
hyphenToSpace: true,
useTitleFromFileHeading: true,
useTitleFromFrontmatter: true,
}),
We can see that the sidebar is rendered, while there are two problems:
- the rendered link for
/src/idea/1.md
islocalhost:5713/1.html
while it is supposed to belocalhost:5713/idea/1.html
- type conflict
do you plan to add this feature? for the moment, is there any workaround for the first problem?
well for the moment I use vite-plugin-vitepress-auto-sidebar, it has sideBarResolved
and sideBarItemsResolved
options to modify the sidebar items in a finer-grained way.
Hello, Thank you for using vitepress-sidebar
and for your feedback.
I have released a new version 1.8.0 with support for multiple sidebars.
Could you please refer to the description in the updated README.md
to see if your request is addressed?
https://github.com/jooy2/vitepress-sidebar#multiple-sidebars-how-to
Thanks.
Hi, thanks for your enhancement. It works well, but I'm confused by the readme file.
By my understanding, the api you design in the readme file is:
generateSidebar([
{
documentRootPath,
rootGroupText,
scanStartPath,
resolvePath,
}
]);
which supposed to produce:
{<resolvePath>: [
{
text: <rootGroupText>,
items: [{ text: 'sub-file', link: '<scanStartPath>/sub-file' }]
}
]
}
right?
But this actually produce when I tried:
[
{
text: <rootGroupText>,
items: [{ text: 'sub-file', link: '<scanStartPath>/sub-file' }]
}
]
So in order to make it work, I have to use like this
sidebar:{
'manually-set-resolved-path': generateSidebar({
documentRootPath
rootGroupText
scanStartPath
//resolvedPath it's useless!
})
}
In other words, the resolved path doesn't make a difference to the output. Maybe it is not working as you designed, since there is a type conflict for my workaround.
BTW, some suggestions for api names:
- use
srcDir
instead ofdocumentRootPath
, just to keep it coherent with the official one inthemeConfig
- use
text
instead ofrootGroupText
. Keep coherent with the official one and also since it is clear we don't refer it to item text (otherwise it doesn't make much sense to autogenerate a sidebar for those who want to customize item text)
Hello, Thank you for your feedback.
Firstly, the issue you mentioned has been fixed in the newly released 1.8.1 - there was a situation where the resolvePath
option was not working as a multi-sidebar option if there was only one, i've fixed this.
The option names for vitepress-sidebar
are long and i aim to use names that can be contrasted with other options to make it easier for users to understand. Also, since vitepress-sidebar
is a third-party plugin, it can cause confusion if it has the same name as a setting in the official vitepress
.
Regards,
- Now it looks well, thx!
- I understand, just because the name may seem complex at the very first glance, do you think it's better to add the following snippet in readme file? I feel it's clearer.
{<resolvePath>: [
{
text: <rootGroupText>,
items: [{ text: 'sub-file', link: '<scanStartPath>/sub-file' }]
}
]
}
Hello,
I think this is a good explanation, as it may be a little more helpful to many users, so i've updated the following section accordingly.
https://github.com/jooy2/vitepress-sidebar#multiple-sidebars-how-to
I'm glad to hear that the feature is working well, I'll close this issue now.
If you run into any further issues, please create a new issue.
Thanks!