#Custom loader based on existing content collection
3 messages · Page 1 of 1 (latest)
Astro’s content collections don’t support “deriving” one collection directly from another out of the box, and the knowledge sources don’t describe a built‑in way to have a work collection automatically mirror or slice entries from an existing projects collection.
What is supported is:
- Every collection must define its own
loader(built‑inglob()/file(), an inline async function, or a custom loader object). [Defining collections; Loader types] - Custom/inline loaders can fetch from any source (filesystem, API, etc.) and return entries with an
id. [Building a custom loader]
However, the docs do not show or mention using one collection’s entries as the data source for another collection’s loader. So:
- You can define
projectsandworkas separate collections, each with its own loader and schema. - You can relate them via
reference()fields (e.g.projectsentries referencingworkentries, or vice versa) and then resolve those references withgetEntry()/getEntries()when rendering. [Defining collection references; Accessing referenced data]