Use-case: we have a centralized "core" documentation repository that is used by several projects.
Certain pages should be hidden for each of those projects.
Vitepress's srcExclude config item allows us to provide a list of the pages to be excluded, and vitepress will not process/bundle those pages. (This list is programmatically created by searching for a specific, locally-defined frontmatter parameter.)
We use vitepress-sidebar to create the sidebar, so we also need to remove the page from the sidebar list. We can't use 'exclude' frontmatter, since this page is not always hidden (depends on the project being built)
Problem: It would be great if we could pass the same list of files from srcExclude to vitepress-sidebar's excludeFiles option. Unfortunately, we discovered that excludeFiles ONLY matches the filename, not the full path. So this doesn't work if there are duplicate filenames living in the tree.
Example: I want to hide /path/to/index.md, but I have 57 other index.md files living in the tree. There is no way to hide /path/to/index.md currently with excludeFiles without hiding the other pages, since it only matches on the entry index.md.
Solution: Match on full pathnames. (More elaborate solution: merge excludeFiles and excludeFolders and have a single exclusion config item, like .vitepress srcExclude, that uses fast-glob - since that captures both the individual file and the folder exclusion use-cases.)
Alternative Solution: Add a callback function (e.g. excludeCallback) that passes the page name and frontmatter to the callback, and allow the callback to return true/false whether to exclude the page.
Solution: Apologies there is no MR here, but since this could be implemented in a number of different ways it would be premature to decide a solution at this time.
Use-case: we have a centralized "core" documentation repository that is used by several projects.
Certain pages should be hidden for each of those projects.
Vitepress's srcExclude config item allows us to provide a list of the pages to be excluded, and vitepress will not process/bundle those pages. (This list is programmatically created by searching for a specific, locally-defined frontmatter parameter.)
We use vitepress-sidebar to create the sidebar, so we also need to remove the page from the sidebar list. We can't use 'exclude' frontmatter, since this page is not always hidden (depends on the project being built)
Problem: It would be great if we could pass the same list of files from srcExclude to vitepress-sidebar's excludeFiles option. Unfortunately, we discovered that excludeFiles ONLY matches the filename, not the full path. So this doesn't work if there are duplicate filenames living in the tree.
Example: I want to hide
/path/to/index.md
, but I have 57 other index.md files living in the tree. There is no way to hide/path/to/index.md
currently with excludeFiles without hiding the other pages, since it only matches on the entryindex.md
.Solution: Match on full pathnames. (More elaborate solution: merge excludeFiles and excludeFolders and have a single exclusion config item, like .vitepress srcExclude, that uses fast-glob - since that captures both the individual file and the folder exclusion use-cases.)
Alternative Solution: Add a callback function (e.g. excludeCallback) that passes the page name and frontmatter to the callback, and allow the callback to return true/false whether to exclude the page.
Solution: Apologies there is no MR here, but since this could be implemented in a number of different ways it would be premature to decide a solution at this time.