-
-
Notifications
You must be signed in to change notification settings - Fork 199
fix(plugin-auto-nav-sidebar): Exclude config.route.exclude files from auto-generated sidebar #899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(plugin-auto-nav-sidebar): Exclude config.route.exclude files from auto-generated sidebar #899
Conversation
…exclude files from auto-generated sidebar
…ion, fixed globby import, fixed empty folder appearing in sidebars, fixed changeset
✅ Deploy Preview for aquamarine-blini-95325f ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
| // If the `_meta.json` file doesn't exist, we will generate the sidebar config from the directory structure. | ||
| const subItems = await fs.readdir(workDir); | ||
|
|
||
| const includedFiles = globby.sync('**', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here globby.sync will traverse all the files and subdirectories under the directory but we only want to traverse the first level. You can change the params as follows:
globby.sync('*', {
cwd: workDir,
ignore: excludedFiles ?? [],
expandDirectories: false,
onlyFiles: false,
});There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @sanyuan0704
This doesn't work for the use case assets/**/* I used in my original issue. With assets/**/* it is necessary to match the files under the directory.
I will still add expandDirectories: false + my second method because I think users excluding assets/**/* will be fine excluding assets/**
|
Sorry, this PR's time was too long and had to be closed. Now this part of the code has been completely refactored in V2, and the implementation should be simpler. Because it is equivalent to a sidebar link, to implement it as a part of |

Summary
When no
_meta.jsonis found, instead of going through all children, useglobbyto exclude files defined inconfig.route.exclude.Related Issue
#848 [Bug]: Excluded routes still appear in the no-config sidebars
Checklist
pnpm run change.