-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
CollectionDoesNotExistError
on fresh install of "Astro Starter Kit: Blog"
#7406
Comments
I have found the issue, and it's a weird one 👽 This is the path I had put my astro install in:
Notice the folder
...the content collections are starting to work. Out of curiosity I also tested it with only one underscore ( |
@hirasso wow, thank you for posting the solution. I've been fighting with this error for the last 2 days. Sure enough, a folder named "_Projects" was the culprit! Definitely a bug, and one that would be an incredibly difficult one to trouble shoot for most people. |
I'm guessing the bug is here: astro/packages/astro/src/content/utils.ts Lines 288 to 297 in d2020c2
We do only check for the underscore within the project root ( |
CollectionDoesNotExistError
on fresh install of "Astro Starter Kit: Blog"
I just deactivated this function and ran the test again – turns out it's not related to the described bug. This is what I did:
Got the same error |
Something seems to be going wrong in astro/packages/astro/src/content/vite-plugin-content-virtual-mod.ts Lines 210 to 213 in 869197a
|
Ran a test. This is the current output from [
'/src/content//**/*{.md,.mdx}',
'!**/_*/**{.md,.mdx}',
'!**/_*{.md,.mdx}'
] The problem is that the negation patterns are being matched on the full path. Changed the function to this: function globWithUnderscoresIgnored(relContentDir: string, exts: string[]): string[] {
const extGlob = getExtGlob(exts);
- return [`${relContentDir}/**/*${extGlob}`, `!**/_*/**${extGlob}`, `!**/_*${extGlob}`];
+ return [`${relContentDir}**/*${extGlob}`, `!${relContentDir}_*/**${extGlob}`, `!${relContentDir}_*${extGlob}`];
} This fixed the content collections for me 🎉 A drive-by improvement would be that the double function globWithUnderscoresIgnored(relContentDir: string, exts: string[]): string[] {
const extGlob = getExtGlob(exts);
const contentDir = addTrailingSlash(relContentDir).trim();
return [`${contentDir}**/*${extGlob}`, `!${contentDir}_*/**${extGlob}`, `!${contentDir}_*${extGlob}`];
}
function addTrailingSlash(path: string): string {
return path.endsWith('/') ? path : `${path}/`;
} |
What version of
astro
are you using?2.6.4
Are you using an SSR adapter? If so, which one?
No
What package manager are you using?
npm
What operating system are you using?
Mac
What browser are you using?
Chrome
Describe the Bug
I installed the "Starter Kit: Blog" from https://github.com/withastro/astro/tree/main/examples/blog
When I run
npm run dev
, the dev server starts and I can visit the site onlocalhost:3000
. The home (/
) and/about/
pages work as expected, but on the/blog/
page, I am getting aCollectionDoesNotExistError
:Any idea what's happening here? I haven't changed anything, just
npm create astro@latest -- --template blog
and said "yes" to all questions. The weird thing is that the demo on stackblitz works just fine...Link to Minimal Reproducible Example
https://github.com/hirasso/astro-starter-kit-blog
Participation
The text was updated successfully, but these errors were encountered: