-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[v6] New content collections guide includes live collections #12604
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
base: v6
Are you sure you want to change the base?
Conversation
…Live Data to focus on using content (not loader building)
…nt seem less overwhelming
…available earlier
✅ Deploy Preview for astro-docs-2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
Yes, the advantage to talking about loaders first, and |
|
I reread everything and I didn't spotted any issue with the organization or the wording, this looks good to me! Because it was easier to create a PR than creating multiple review comments, here's my suggestions: #12685 I also noticed something unclear regarding the import of the loader errors classes, maybe Matt can confirm where they should be imported from. In two code snippets we were importing |
yanthomasdev
left a comment
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.
Is it final boss time?
Co-authored-by: Sarah Rainsberger <[email protected]> Co-authored-by: yanthomasdev <[email protected]>
Co-authored-by: Yan <[email protected]>
Co-authored-by: Yan <[email protected]>
HiDeoo
left a comment
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.
Left a few thoughts and suggestions but this looking really great! So many improvements all around while incorporating new content at the same time. 👏
Co-authored-by: HiDeoo <[email protected]> Co-authored-by: Yan <[email protected]>
Co-authored-by: HiDeoo <[email protected]>
Co-authored-by: HiDeoo <[email protected]>
…o/docs into stable-live-collections
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.
See what you think of the updated example! This doesn't look bad to me to show how is() works. Nice idea!
Edit: updated based on T&D feedbacks to remove is()
ArmandPhilippot
left a comment
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.
Based on T&D, we also need to update two other places in addition to my previous suggestions.
Co-authored-by: Armand Philippot <[email protected]>
ArmandPhilippot
left a comment
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.
Except one wrong use of slug, I think everything is correct here. And maybe we could reduce the confusion by swapping a valid example.
Co-authored-by: Armand Philippot <[email protected]>
| } | ||
| ``` | ||
|
|
||
| <ReadMore>See [how to create a live loader](/en/guides/content-collections/#creating-a-live-loader) with example usage.</ReadMore> |
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.
@ascorbic The example shown here on the Loader API page is the same as the one shown in the content collections guide. The content in both places here is pretty much identical.
Do you have a preference for where this example lives, here in reference or in the guide?
(Either way, this note should go because it doesn't provide any additional info)
| The API for [inline loaders](#inline-loaders) is very simple, and is shown above. This section shows the API for defining an object loader. | ||
| The API for [inline loaders](#inline-loaders) is very simple, and is shown above. This section shows the API for defining an [object loader](#object-loaders). | ||
|
|
||
| ### The `Loader` object |
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.
@ascorbic Also noting we show no code examples for a lot of these properties, and not even one big "example loader object" to start. Maybe this could be more helpful with some code?
|
@ascorbic I left a couple of quick comments above, otherwise, I think everyone who intends to has left feedback here and I've addressed it! Would be great if you could do a final pass review on (deploy preview links): And, of course, no worries if you notice something drastic and want big changes! There's still lots of time! But, I think everyone else has exhausted themselves, so we'll need fresh eyes for anything much new to happen. 😄 |


Description (required)
This PR updates the Content Collections guide so that it describes and differentiates the two types of collections we will have stable in v6: build-time and live. It also updates entries in the
astro:contentmodule reference page and the Content Loader API page:astro:contentmodule referenceThis incorporates content from the current existing Experimental Live Collections reference page into the new main content collections guide page.
My thoughts throughout this PR:
It is important to name and distinguish the two types of collections (build-time and live)
the two built-in build time loaders (
glob()andfile()) now have their own, clear, discoverable sections.The natural order of "setting up a collection" is still: define it, add a loader, most likely add a schema; then you're able to query/filter and render; oh, and you probably are going to want dynamic pages based on your entries. So, I've kept that overall structure. Build time and live collections are split out into discrete sections, each following that pattern, based on feedback.
Did I say I added a LOT of internal page linking?? One big challenge here is that setting up a simple blog with local Markdown files is much less complicated than needing to build your own live loader. Frankly, there's a crap ton of loader content, but you can't do anything until you have a loader so it feels difficult to offload it to the bottom of the page and just say "go off here to learn about loaders so I can show you the rest of content collections". (see next point)
My solution here is the "Types of Collections" section at the beginning with informative, skeleton content that addresses EVERYTHING with links (defining, querying, rendering, generating pages) for each of build and live collections. e.g. As long as you read the short "Build-time content collections", you'll be armed with everything you need to know via direct links to each section you care about.... including a tip to go look at the Astro Blog starter template to see a simple build-time collection in action for a "quick start" approach. (The same is true about the "Live content collections" section: it provides a good overview of the "getting set up" steps with links to identify all the links in the chain. But sorry, you're going to have to figure out how to build a live loader before you can actually do anything.)
We now need to differentiate between "build-time rendered on demand" and "live collections", so I've tried to add a few nods to that. (It's possible to have build-time collections that are built once, upon first request and their content added to the data store layer vs. live collections which are always (re)fetched fresh at each individual request time.)
Since people prefered splitting up build time and live collections into their own headings (
##), we're showing headings from##to####in the TOC. I think this is necessary now because most content is now a heading level lower, including stuff that is helpful to have visible.Lots of section headings have changed, so there was some link damage to fix up.
Comment threads "resolved" to maybe loop back around to
Should there be a "When to use each type of collection" vs the few bullet points at the beginning of each of Build-time and Live Collections?I reorganized content so that this is included without needing a separate heading, I think.- I (Sarah) am fairly strongly in favour of keeping the distinction since the API are different (though the helper functions names have been made to be similar). "Querying some files" is different from "fetching some data live", and I personally like the headings reflecting this I also think this makes for better page navigation (allows each heading to be distinct and less likely to get them mixed up or click on the wrong one). But, right now I think it's only Oliver and I that have weighed in with an opinion here! Others are welcome to give feedback on this!
Live collections limitations and differences from build time are currently sections at the bottom of the page as "further reading", but linked to from the main entry on live collections for those who need to read further. My concern with putting them up is "making someone get PhD in everything Live Collections" before they get to read more. This feels like info that is OK to just be available/accessible as long as it's clearly linked to as we've done.I've worked this content in without section headings (keeps the table of content simpler) in the introductory section.For Astro version:
6.0. See astro PR #14550.