Closed Jackiexiao closed 3 months ago
Hello! Thank you for using vitepress-sidebar
and for supporting the project!
You can utilize the Frontmatter syntax and the useTitleFromFrontmatter
option to set the index file to any name you want.
The advantage of this option is that it can be applied only to the specific file you want, unlike the useTitleFromFileHeading
option, which is done for the entire file.
For example, in the index.md
file, fill in Frontmatter's title
field like this:
---
title: The title that appears in the menu
---
# The title that displayed in article content (but not in the menu)
The parts of the vitepress-sidebar
that need to be set up are:
export default defineConfig({
themeConfig: {
sidebar: generateSidebar({
includeRootIndexFile: true, // If you don't want to display the index file, clear this option or leave it `false`.
useTitleFromFrontmatter: true
}),
}
});
Result:
If this doesn't solve your problem, or doesn't meet your needs, please leave a reply.
Regards,
thx!!!!! It works!
This is my final configuration for reference.
collapsed: true,
collapseDepth: 2,
includeRootIndexFile: true,
useTitleFromFrontmatter: true,
sortMenusOrderNumericallyFromTitle: true,
prefixSeparator: '.',
removePrefixAfterOrdering: true,
In index.md
---
title: 1.xxx
---
and docs/ looks like
index.md
2.xxx.md
3.xxx.md
It can ensure that index.md is in the first position. And it ensures that all other files are sorted according to the number at the beginning, and the number prefix is removed when finally displayed.
Thanks for sharing your workaround, i'm glad to hear it worked for you!
Hello! Appreciation is extended for the creation of this excellent plugin!
I am curious as to how to incorporate the
includeRootIndexFile
while rechristening the index file to an alternative name?The 'useTitleFromFileHeading' appears to have an impact on all other files, and it also conflicts with the'removePrefixAfterOrdering' setting.