-
Notifications
You must be signed in to change notification settings - Fork 132
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
base: main
Are you sure you want to change the base?
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. |
@@ -32,7 +34,15 @@ export async function scanSideMeta( | |||
sideMeta = (await fs.readJSON(metaFile, 'utf8')) as SideMeta; | |||
} catch (e) { | |||
// 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/**
Summary
When no
_meta.json
is found, instead of going through all children, useglobby
to exclude files defined inconfig.route.exclude
.Related Issue
#848 [Bug]: Excluded routes still appear in the no-config sidebars
Checklist
pnpm run change
.