Integration Collections
Installing the dependency
Collection Injection
Sometimes an integration would prefer to accept content or configurations in the form of content/data collections. This can be useful when injecting dynamic pages that require specific field of an integration or when configuring a theme.
injectCollections
AIK-style utility for integrations to declare their own content collections.
It accepts an entrypoint
which should have the same exports as the src/content/config.ts
would for a normal collection.
Additionally, you can provide a seedTemplateDirectory
along with your entrypoint. If you do, a call to seedCollections
is implied using that path the template.
@it-astro:content
virtual module
This virtual module provides the same API as astro:content
, with the exception of defineCollection
. Instead, defineCollection
creates a FancyCollection
, that can be extended by users of your integration.
For integration authors, it is a drop-in replacement.
Users of your integration would then be able to extend the schema like so:
Collection Seeding
If you want to provide some initial content for collections used by your integration so your users know where to start, you can provide a seed for your collections.
seedCollections
AIK-style utility for integrations to declare a seed for collections.
It received the absolute path to a directory that should contain collections in the same structure as expected by Astro, each folder inside of it should have the name of the collection and it’s contents should follow a set schema.
For example, if you have the following file structure:
- integration.ts
DirectorycollectionTemplates
DirectorydarculaColors
- blog.json
- landingPage.json
You can declare the seed like so: