component | components
The component and components properties are used to define an atom relationship.
These definitions can be static, where a property references another atom, or dynamic, where a property can have one-or-many components.
When defining a static relationship, the component will be pre-generated in the admin.
Component
import { atom, component } from '@iridiumcms/core';
export const sample = atom('sample', {
myCta: component('cta'),
});
The component field takes either an atom name and optional configuration object or a optional configuration object:
- nameThe name of the atom to reference.
string - displayNameThe display name of the field. Defaults to the name of the property.
string - showLabelSet to
booleanfalseto hide the property name in the admin. Defaults totrue. - requiredWhether the field is required. Defaults to
booleanfalse. - isStaticSet to
booleanfalseto make the property optional and disable the admin from pre-generating the component structure. - layoutThe layout of the field in the admin. Defaults to
LAYOUTLAYOUT.full.
Components
import { atom, components } from '@iridiumcms/core';
export const sample = atom('sample', {
myCtas: components('cta'),
myContent: components([
'headline',
'feature',
'boxes',
]),
});
The components field takes atom references as an allow list. The admin will only allow the user to create components that are defined in the names array. This is similar to repeaters in other content management systems.
- an string of an atom name
- an array of atom names
- an object with the following properties:
- namesThe name(s) of the atom(s) to allow.
string | string[] - isRepeatableAllows multiple of the same component to be created. Defaults to
booleantrue. - minThe minimum number of components to create. Defaults to
number0. - maxThe maximum number of components to create. Defaults to
numberInfinity. - displayNameThe display name of the field. Defaults to the name of the property.
string - showLabelSet to
booleanfalseto hide the property name in the admin. Defaults totrue. - requiredWhether the field is required. Defaults to
booleanfalse. - isStaticSet to
booleanfalseto make the property optional and disable the admin from pre-generating the component structure. - layoutThe layout of the field in the admin. Defaults to
LAYOUTLAYOUT.full.
