Fields define the shape of the content and the user input. There are many types of fields each with its own input and type.
Although some fields have more properties here is a list of common ones that are used.
Property | Description |
name | The name of the field |
type | The type of the field to be used |
label | A human friendly label that will be displayed to the user (optional, defaults to name ) |
required | If true , the collection cannot be saved without this field present (optional, defaults to false ) |
isTitle | Denote a field as the title of a collection. See below for more details (optional, defaults to false ) |
isBody | If true this field will be used as the body of the document. See below for more details (optional, defaults to false ) |
nameOverride | An optional property to allow exporting a field with a special character, that wouldn't be supported by the name property. E.g: { name: 'custom_id', nameOverride: 'id' } or { name: 'my_field', nameOverride: 'my-field' } . When a document is written/read to/from GitHub, the nameOverride will be used as the frontmatter field key, instead of the name . |
ui | Used to extend the user interface of the field and the field behavior. See extending tina section for more information (optional) |
ui.list | This can be used to make any field into a list of that type (optional) |
ui.min | If { list: true } can provide a minimum amount of items (optional) |
ui.max | If { list: true } can provide a maximum amount of items (optional) |
ui.component | Used for custom field components |
ui.validate | Used for custom field validation |
isTitle
isTitle
can be used to denote which field represents the title of the document. The field set with isTitle=true
is what is displayed in the CMS list view page.
Make sure the following is true when using isTitle
collections.fields
or collections.templates.fields
)required
is set to trueisTitle
export default defineConfig({//...schema: {collections: [{name: 'posts',label: 'Blog Posts',path: 'content/posts',format: 'mdx',fields: [{type: 'string',label: 'Title',name: 'title',isTitle: true,required: true,},// ... other fields],},],},})
isBody
isBody
can be used for "mdx"
, "markdown"
, and "md"
formats. The field used for isBody = true
must have type string
or rich-text
. When isBody
is true it will save that field to the body of the document.
isBody
export default defineConfig({//...schema: {collections: [{name: 'posts',label: 'Blog Posts',path: 'content/posts',format: 'mdx',fields: [{type: 'rich-text',label: 'Body of post',name: 'body',isBody: true,},//... Other fields],},],},})
Last Edited: June 15, 2022
Product
Resources
© TinaCMS 2019–2024