Closed emersonbottero closed 1 week ago
Hello! Thank you for using vitepress-sidebar
.
Doesn't your requirement also work with the useFolderLinkFromIndexFile
option set to true
?
This option will create a link in the folder to the index.md
file. You can add only a single link to a folder without displaying the index.md
file. However, you can still display the index.md
file if you use the includeFolderIndexFile
option with it.
The screenshots you attached all appear to be working as intended. If you could describe the issue you're ultimately facing, and how you set it up or reproduce it, we'd be happy to take a look.
Regards,
Hi. that is exacly the problem, first screenshoot..
As I said does not make Sense to show
Comands
_ Comand states
_ index (link)
Comand states
index (link)
_ Comand states
_ index (link)
Comand states
index (link)
_ index (link)
it shoudl show
option 1
Comands (link)
Comand states (link)
Comand states (link)
Comand states (link)
Comand states (link)
or at least
option 2
Comands
Comand states (link)
Comand states (link)
Comand states (link)
Comand states (link)
_ index (link)
all my effords to make one of the 2 above options failed in screenshot 2 and 3.
P.S: If the docs where written from scratch it would be easier to follow the side_bar_name.md approach, but as I said I'm migrating an existing doc not written in vitepress at the start.
P.S2: your plugin is awesome.. my request could be considered a new feature although I think it should be the default behavior. The only downside of option 1 is that a group having a link make it expand/contract when you just want to fothe the link, or it goes to the link when you only want to expand/contract. but I'm ok with option 3 if you think it makes more sense. 😁
I added this code to achieve what I wanted..
export const cleanNavItems = (sidebar) => {
sidebar.forEach(element => {
if (element.items && element.items.some(i => i.text == "Index")) {
element.link = element.items.find(e => e.text == "Index").link
element.items = element.items.filter(e => e.text != "Index")
if (element.items.length == 0) {
delete element.items
} else
return cleanNavItems(element.items)
}
else {
return element.link
}
});
return sidebar
}
and you can see the result here
Hello,
Thank you for your detailed explanation. I was able to understand your issue.
However, as mentioned above, it seems that setting the useFolderLinkFromIndexFile: true
option along with the includeFolderIndexFile: false
option will achieve your requirement.
I was able to achieve the result on the left without using cleanNavItems
in your repository, as shown in the photo below.
The code in https://github.com/jooy2/vitepress-sidebar/issues/178#issuecomment-2354397888 that removes the object attribute if the items
item is empty has been modified to reflect the new version 1.27.0
that I just updated. The presence or absence of items: []
or not has no effect on the menu, but i thought it should be clearer, so we fixed it.
I know it's a hassle, but could you please upgrade to 1.27.0
and follow the settings below to see if that resolves your issue? Please leave us a reply and we'll continue to check your issue. Thank you.
const vitepressSidebarOptions = {
// debugPrint: true,
documentRootPath: "/docs",
// resolvePath: "/docs",
// includeRootIndexFile:true,
useFolderLinkFromIndexFile: true,
hyphenToSpace: true,
capitalizeFirst: true,
// includeFolderIndexFile : true,
// includeEmptyFolder: true,
collapsed: true,
excludeFolders:["_assets","_includes","_layouts","_legal","_src", "changelog"],
};
Yes it worked.
Thank you for letting me know. I'll consider this issue closed, but feel free to open a new issue if you have any new concerns!
Describe the bug A clear and concise description of what the bug is.
vitepress supports folder/index.md and foders/sub-folders/index.md with a sidebar that should not be a group.
To Reproduce Steps to reproduce the behavior: folder/index.md should generate a sidebar Folder with a link to folder/index.md. if includeFolderIndex is true the link should be as above if the group has no other sublinks.
Expected behavior A clear and concise description of what you expected to happen. folders with only an index.md should not become groups.
Screenshots If applicable, add screenshots to help explain your problem.
including empty folder creates groups with no links
removing empty folder and index and no sidebar shows at all..
Desktop (please complete the following information):
Additional context Add any other context about the problem here.