Fix: Content Collections - Ignore .json
files nested in non-underscored subdirectories within underscored directories
#7909
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Change glob pattern to exclude files in underscored directories from
!${contentDir}**/_*/**${extGlob}
to
!${contentDir}**/_*/**/*${extGlob}
This allows for all files in a directory prefixed with an
_
to be ignored regardless of how nested the file is.Details
This PR is related to issue #7154.
Previously, PR #7246 and #7268 addressed ignoring files prefixed with an
_
(i.e._underscored-file.json
) and files that are direct children of an underscored directory (i.e._underscored-dir/non-underscored-file.json
). However, it did not address the case where a file is in a non-underscored subdirectory of an underscored directory (i.e._underscored-directory/non-underscored-dir/non-underscored-file.json
).Glob pattern checked with globster.
Testing
A new file was added under test fixtures for content collections at:
astro/packages/astro/test/fixtures/content-collections/src/content/with-schema-config/_ignore/ignore/file.md
With this file and without the fix on this PR, running
pnpm run test:match "with schema"
will result in tests failing.Docs
N/A