Each item in your collections array represents its own entity. In the above example, we defined a post collection, and set its path as content/posts, which maps to a directory in our site's repository. Each collection contains an array of fields, that each have a defined type.
---title: This is my title---This is my main post body.
Note: TheisBodyproperty is used to output a given field to the markdown body, instead of its frontmatter.
Once we've defined a collection, we can edit its fields through the Tina UI, or query its content using the Tina Content API.
An object type takes either a fields or templates property (just like the collections definition). The simplest kind of object is one with fields:
// ...fields: [{label: 'Testimonial',name: 'testimonial',type: 'object',fields: [{label: 'Author',name: 'author',type: 'string',},{label: 'Role',name: 'role',type: 'string',},{label: 'Quote',name: 'quote',type: 'string',ui: {component: 'textarea',},},],},]// ...
Setting list: true would turn the values into an array.
More complex shapes can be built by using thetemplatesproperty. This allows your editors to build out pages using predefined blocks.
The reference field connects one document to another and only needs to be defined on one side of the relationship. You can specify any number of collections you'd like to connect:
// ...fields: [// ...{label: 'Author',name: 'author',type: 'reference',collections: ['author'], // points to a collection with the name "author"},]//
Each field in a collection can be of the following type:
For those who prefer to learn from video, you can check out a snippet on media from our "TinaCMS Deep Dive" series.
tina/config.{ts,js,tsx} in your repo using defineConfig.