Components
Components are reusable field definitions. Define one under components, then reference it from any field with component instead of type.
components:
seo:
type: object
label: SEO
fields:
- name: title
type: string
- name: description
type: text
- name: image
type: image
content:
- name: pages
type: collection
path: src/content/pages
fields:
- name: title
type: string
- name: seo
component: seo
- name: posts
type: collection
path: src/content/posts
fields:
- name: title
type: string
- name: seo
component: seo
label: Search enginesA component is a field definition without name. The field that uses it supplies the name and can override other keys: above, the second seo field shows "Search engines" instead of "SEO".
- If the component sets
type, a field can't change it. - Objects such as
optionsare merged with the component's, key by key. - Lists such as
fieldsreplace the component's list.
Components can use other components, but not themselves, directly or through another component.
Components are especially useful as blocks:
- name: sections
type: block
list: true
blocks:
- name: hero
component: hero
- name: features
component: featuresComponent names use letters, numbers, - and _.