Content collections: ignored underscore directories in file glob (#7268)
* fix: ignored underscore dirs in glob * chore: changeset
This commit is contained in:
parent
6533041ce0
commit
9e7366567e
2 changed files with 23 additions and 6 deletions
5
.changeset/rotten-pens-destroy.md
Normal file
5
.changeset/rotten-pens-destroy.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix: ignore `.json` files within content collection directories starting with an `_` underscore.
|
|
@ -44,14 +44,21 @@ export function astroContentVirtualModPlugin({
|
||||||
)
|
)
|
||||||
.replace('@@CONTENT_DIR@@', relContentDir)
|
.replace('@@CONTENT_DIR@@', relContentDir)
|
||||||
.replace(
|
.replace(
|
||||||
'@@CONTENT_ENTRY_GLOB_PATH@@',
|
"'@@CONTENT_ENTRY_GLOB_PATH@@'",
|
||||||
// [!_] = ignore files starting with "_"
|
JSON.stringify(globWithUnderscoresIgnored(relContentDir, contentEntryExts))
|
||||||
`${relContentDir}**/[!_]*${getExtGlob(contentEntryExts)}`
|
|
||||||
)
|
)
|
||||||
.replace('@@DATA_ENTRY_GLOB_PATH@@', `${relContentDir}**/[!_]*${getExtGlob(dataEntryExts)}`)
|
|
||||||
.replace(
|
.replace(
|
||||||
'@@RENDER_ENTRY_GLOB_PATH@@',
|
"'@@DATA_ENTRY_GLOB_PATH@@'",
|
||||||
`${relContentDir}**/*${getExtGlob(/** Note: data collections excluded */ contentEntryExts)}`
|
JSON.stringify(globWithUnderscoresIgnored(relContentDir, dataEntryExts))
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
"'@@RENDER_ENTRY_GLOB_PATH@@'",
|
||||||
|
JSON.stringify(
|
||||||
|
globWithUnderscoresIgnored(
|
||||||
|
relContentDir,
|
||||||
|
/** Note: data collections excluded */ contentEntryExts
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const astroContentVirtualModuleId = '\0' + VIRTUAL_MODULE_ID;
|
const astroContentVirtualModuleId = '\0' + VIRTUAL_MODULE_ID;
|
||||||
|
@ -189,3 +196,8 @@ const UnexpectedLookupMapError = new AstroError({
|
||||||
...AstroErrorData.UnknownContentCollectionError,
|
...AstroErrorData.UnknownContentCollectionError,
|
||||||
message: `Unexpected error while parsing content entry IDs and slugs.`,
|
message: `Unexpected error while parsing content entry IDs and slugs.`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function globWithUnderscoresIgnored(relContentDir: string, exts: string[]): string[] {
|
||||||
|
const extGlob = getExtGlob(exts);
|
||||||
|
return [`${relContentDir}/**/*${extGlob}`, `!**/_*/**${extGlob}`, `!**/_*${extGlob}`];
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue