-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Content collection loader examples are inconsistent #10300
Comments
Hi, thanks for reporting this and volunteering to fix the docs! Regarding the backslash: Regarding the consistency between the patterns: However, I agree, the |
Does the router exclude files with underscores even if the pattern is If the router behavior depends on this pattern, that complicates the issue. |
I don't think so, and that's probably why this pattern is used in the upgrade guide. So I think it's best to leave it there! If patterns were to be standardized, it would probably be safer to use |
I think I know a way to make it clearer.
I can see if anyone else has a different thought as well. |
Just a precision: It is still the case, but this applies to files in Regarding your suggestions:
I suggested to wait for another opinion because I am not a maintainer here, just a contributor so my opinion doesn't count more than yours and like I said I don't know what's best here! I just wanted to point out that standardization may not be that simple. It's still the weekend, I'm sure other people will be able to chime in later. 😉 In any case, a PR to remove the unnecessary escape character is very welcomed! And, thanks for your ideas! Let's see what others think! |
Firstly, thanks for catching the Just chiming in here that Armand has given a great summary of the position and why "consistent" examples are problematic:
I'll take a peek at the upgrade guide and see where a very quick mention of this change might make sense. The part about excluding draft posts by filtering queries was present even in the old content collections docs, so I don't think we need to have an example of going back to old behavior. It's merely that the shortcut convenience no longer works, and in fact was possible to control more finely with the suggested filtering method anyway. But you're right, if this is a behaviour people were relying on previously, it makes sense to point it out in the upgrade guide! And, we could additionally maybe make it even more explicit on the routing page that this pattern is for only page/endpoint/route files within I can see the PR for excluding the backslash, and I'll get that merged in shortly! |
It seems that the new behavior is not clear to everyone. There is a new issue in the core repo about this, see: withastro/astro#12730. In Exclude pages, maybe we could:
-You can exclude pages or directories from being built by prefixing their names with an underscore (_).
+You can exclude pages or directories within `src/pages` from being built by prefixing their names with an underscore (_).
To exclude pages from your content collections, you need to [adapt the `pattern` of your glob loader](https://docs.astro.build/en/guides/content-collections/#built-in-loaders). This doesn't show exactly which pattern to use, but it might help to better understand how it works and where to look for... |
Yes, I think those are great changes! It is probably also still worth a shout out in the upgrade guide that the analogous behaviour that had been built in to the old collections API for local content files has been removed, and you can either update your (And just taking this moment to point out how "changing content collections" obviously doesn't just mean "updating the content collections page in docs"! We tried to anticipate as much as we could and update the entire docs for all these v5 changes, but there are a lot of interconnected pieces. Thank you everyone for helping us spot what we missed, participating in improving it, and having the patience while we get eventually get there! 💜 ) |
Sounds good. Shall I have a go at some of these updates? |
@anaxite I would love that! I think incorporating Armand's suggestions and running with those make sense. We can edit/polish final details in the PR. Once you start, I'll add something to the PR on the upgrade guide. (That one I'll probably want to word myself, since there's already so much info on that page I'll want to fit this in as compactly as I can.) |
Add note that underscore exclusion is only for `src/pages`.
@sarah11918 Alright, PR is started! I'm leaving it in draft mode until I've had more of a look. I started in the routing page with Armand's suggestion, and updated the file tree block at the bottom to make it look a bit more different to content collections. |
📚 Subject area/topic
Content collections
📋 Page(s) affected (or suggested, for new content)
📋 Description of content that is out-of-date or incorrect
The Astro v5 loader examples have a different file pattern depending on the page. The different examples are confusing, and it's not sure which pattern is the recommended default.
For example, the upgrade guide shows a loader pattern that excludes underscore:
The astro:content reference removes the underscore check:
The MDX integration guide adds a backslash:
I am willing to submit a PR if I know the recommended format.
🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)
No response
The text was updated successfully, but these errors were encountered: