map templates
You can use map: { ... }
templates, that generate a single file. In the map
object, you define "name": "data-collection-id"
or "name": ["first-data-collection-id", "second-data-collection-id"]
key-pairs.
In the filename
frontmatter field, the render context will contain a field for each key in the map
object, and the value of the key will be the an array of all the data objects in the data collection.
Example map
template:
{
"map": {
"entities": "entities"
},
"filename": "README.md"
}
---
# Entities
This readme contains all entities in the system.
Version: `{{$.version}}`
{{#each entities}}
## {{name}}
{{description}}
{{/each}}
When to use arrays?
Defining map
as an array comes in handy, when you have multiple data collections sharing the same schema.
One particular example is if you have a query that produces some objects, and also a data collection that adds "manual instances" of the same schema.
Then you would say:
{
"map": {
"entities": ["generated-entities", "entities"]
},
"filename": "README.md"
}
---
# Entities
This readme contains all entities in the system.
Version: `{{$.version}}`
{{#each entities}}
## {{name}}
{{description}}
{{/each}}