-
-
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
|
|
(Note that previous commit updates from changes made in #12571 ) |
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 Chris feedback in #12790 I made two suggestions for the cacheHint code snippet.
Edit: Hmm Github is buggy on my side... 👀 The first comment should have removed import { byLastModified } from "./sort"; too... And if I go back to the file diff, I can't even see my suggestions...
…e live loader API stuff
|
We're going to have stuff to look at during Talking and Doc'ing tomorrow 😅 |
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.
The following suggestions should fix the issues @HiDeoo noticed on T&D!
Co-authored-by: Armand Philippot <[email protected]>


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 reference - API reference for things imported fromastro:contentThis incorporates content from the current existing Experimental Live Collections reference page into the new main content collections guide page.
TODO:
LiveData*types are still mostly placeholdersMy 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.