Multiple sidebars generate duplicate part in links
pixel-fabian opened this issue · 5 comments
Describe the bug
We do have 2 major topics in our vitepress instance, very similar to Guide
and Reference
on vitepress.dev.
I would like to autogenerate the sidebars for these topics and also only display the sidebar for the current topic as described in multiple-sidebars-how-to.
I re-checked the docs and our setup and are pretty sure that is should work, but maybe i misunderstood something in the docs?
Folder Structure:
.
├─ .vitepress
├─ topic-1
│ ├─ subtopic-1-1
│ └─ subtopic-1-2
└─ topic-2
├─ subtopic-2-1
└─ subtopic-2-2
The documentation is published at domain.xyz/documentation.
config
{
...
base: "/documentation/",
sidebar: generateSidebar([
{
documentRootPath: "/",
scanStartPath: "topic-1",
resolvePath: "/topic-1/",
useTitleFromFileHeading: true,
collapseDepth: 2,
},
{
documentRootPath: "/",
scanStartPath: "topic-2",
resolvePath: "/topic-2/",
collapseDepth: 2,
},
])
}
The sidebars are generated properly and displayed as expected, but the Links are not correct:
- The resolvePath seems to be part of the link, which generates a duplicate middle part:
- e.g.
/documentation/topic-1/topic-1/subtopic-1-1/page.html
To Reproduce
- Have a setup with two sidebars as described above
Expected behavior
- The link should not contain the 'resolvePath'.
- e.g.
/documentation/topic-1/subtopic-1-1/page.html
If i remove the 'resolvePath' from the config, the links are generated properly, but only the second sidebar is displayed across all topics, as probably expected.
Additional context
- vitepress version: 1.0.0-rc.14
- vitepress-sidebar version: 1.15.0
Also the "sidebar" within the config.mts gives me the following TypeError:
Type 'Sidebar' is not assignable to type 'Sidebar | undefined'.
Type 'SidebarMulti' is not assignable to type 'Sidebar | undefined'
Hello! Thanks for using the plugin and leaving a detailed issue report.
This issue doesn't seem to be a common occurrence, maybe it's a routing issue on your hosting server.
For a quicker troubleshooting, could you please share the output of vitepress-sidebar
?
Setting the debugPrint
option to true
in the sidebar option will print the sidebar creation result in the console. If you have multiple sidebar options, you can specify it only in the first option.
https://github.com/jooy2/vitepress-sidebar?tab=readme-ov-file#debugprint
Regards,
Hi, thanks for the fast response.
It happens also locally on the dev server, so i don't think its related to our hosting server.
The debugPrint:
{
"/topic-1/": {
"base": "/topic-1/",
"items": [
{
"text": "subtopicindex",
"items": [
{
"text": "SubTopic-1-1",
"link": "topic-1/subtopicindex/subtopic-1-1"
}
],
"collapsed": false
}
]
},
"/topic-2/": {
"base": "/topic-2/",
"items": [
{
"text": "subtopic-2-1",
"link": "topic-2/subtopic-2-1"
},
{
"text": "subtopic-2-2",
"link": "topic-2/subtopic-2-2"
},
{
"text": "subtopic-2-3",
"link": "topic-2/subtopic-2-3"
}
]
}
}
From my understanding so far, "topic-1" and "topic-2" should not be part of the link
, because its already the base
, right?
Hello, Thank you for sending me your test results.
I have identified the issue and fixed some issues in the plugin.
Could you please check if the issue persists after upgrading to the new version 1.16.5
of vitepress-sidebar
?
I'm not sure if it's fully resolved for several test cases, but I believe it should be fixed for the above case.
Regards,
Hi,
i can confirm that with version 1.16.5
the sidebars in our project work as expected.
Thank you!
Thanks for sharing your status! If you run into any other issues, please create a new issue.
I'm closing this issue.
Regards,