#Custom loader based on existing content collection

3 messages · Page 1 of 1 (latest)

native shellBOT
#

Hi @copper fern. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

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‑in glob()/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 projects and work as separate collections, each with its own loader and schema.
  • You can relate them via reference() fields (e.g. projects entries referencing work entries, or vice versa) and then resolve those references with getEntry() / getEntries() when rendering. [Defining collection references; Accessing referenced data]
#

But if your goal is “have work automatically be derived from projects without duplicating data,” the knowledge sources do not describe a supported pattern for that. You would need to maintain them as separate collections and connect them via references, or use a shared external data source that both loaders read from.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: