Model Properties
Options available within a single content model definition in the visual editor.
The models property is how content models are specified in the visual editor. This document details the properties available within a model definition.
Usage
Each model is defined as a property within the models property on the primary visual editing configuration object. The name of the property indicates the name of the model (or ID, in some CMSs), while the value is the model definition.
In the example below, we're showing a configuration that defines two models — Page and Post. Within each of these objects can be the options shown below.
1234567891011
See the name property for model naming limitations.
Model Definition Options
The following properties are available when configuring a model definition.
actions
Model actions match global and bulk custom actions, except for the following differences:
typeis inferred and not requiredmodelanddocumentare available within thestateandrunoptions parameter, referring to the document and model on which the action is performed.contentSourceActionsis also available to therunfunction. This is an object that includes the following functions that get passed onto the content source module:createDocumentupdateDocumentdeleteDocumentpublishDocuments
description
Description of the model.
1234567
extends
Models that are extended from other models inherit all fields in the models included in the list. This model can then define any new fields of its own.
12345678910
- If this model declares a field with the same name as a field it inherited, then that field's attributes are merged: any field attributes explicitly set in this model are used. Then, inherited field attributes are used as long as they as not overridden in the model.
- That means you can not only override field attributes fully, but also easily add/change specific attributes of inherited fields, e.g. setting a
defaultfor a field which better matches this model.
- That means you can not only override field attributes fully, but also easily add/change specific attributes of inherited fields, e.g. setting a
fieldGroups
This attribute is used by the editor UI to visually place related fields in separate groups. This has no effect on the content itself or how it is stored - it is only used to make editing content pieces with multiple fields easier.
This attribute works in tandem with the group attribute for fields.
1234567891011
- Any field that does not has an assigned group is put by the editor UI under the default group "Content" (regardless of whether any field groups were defined).
Available Icons
align-centeralign-justifyalign-leftalign-rightangles-rightarrow-downarrow-down-arrow-uparrow-leftarrow-left-from-bracketarrow-rightarrow-rotate-rightarrow-uparrow-up-from-bracketarrow-up-from-squarearrow-up-right-from-squarearrows-rotatebadgebarsbellboldbookmarkcalendarcamera-moviechart-arrow-up-rightcheckchevron-downchevron-leftchevron-rightchevron-upcircle-exclamationcircle-infocircle-questionclockcodecomment-quotecopycredit-cardellipsisellipsis-verticalenvelopeeyefill-dripfilterflaggeargemglobegrid-2grid-dots-verticalimageintegrationitaliclayer-grouplayoutlinklistlist-checklist-ollist-treelocklong-textmagnifying-glassmemominuspagepalettepaperclippastepencilpluspostredoscreen-sizesectionsparklessparkles-fullstarstar-fulltable-listtextthumbtacktrashundoup-right-and-down-left-from-centeruseruser-minususer-plususersxmarkfields
The definition for specifying or overriding fields on a model.
123456789
filePath
The path at which to store new page and data content created by editors using the visual editor. New pages are stored at {pagesDir}/{filePath} and non-page documents are stored at {dataDir}/{filePath}.
123456789
- Single-instance models should point to a specific file, while models with multiple content objects should use variable interpolation to create dynamically-named pages.
- Variables can be interpolated using curly brackets. Examples:
filePath: '{slug}.md'filePath: 'posts/{moment_format(date, 'YYYY-MM-DD')}-{slug}.yaml'
- The UI has special handling for index pages:
- When a user adds a new page and sets its path it
/plans/(note the trailing slash!), the page content will be stored to the file/content/pages/plans/index.md - When you navigate to this page, the UI will know to map the URL
/plans/back to/content/pages/plans/index.md.
- When a user adds a new page and sets its path it
groups
Adds the model to a specific group for use with the groups field attribute.
12345678910111213141516
- When defining fields of type
modelorreferencewhich point to other model names, you may wish to have a list of acceptable model names which is not hard-coded, e.g. "any section-like component is applicable for nesting here", or "any person-like component can be referenced from here". - In the example above, the
CaseStudySectionmodel declares that it belongs in theSectionComponentgroup. Here is how this group name is then used for thesectionsfield in thePagemodel.
hidden
Hides the content model and its documents from being editable in the visual editor.
1234567
- All models and their documents are visible by default.
hideContent
By default, the UI assumes that any page models implicitly have a content field with Markdown-formatted content. When the page is edited in the UI, this field will be available to edit under a field labeled Content.
1234567
- For this functionality to work, defined page model files must have an .md extension.
- For pages whose model declared
hideContent: true, you will find only front matter in files. - Content for a page where
hideContentisfalseis available in a property namedmarkdown_content.
label
A short, descriptive name for the model that is shown to the content editor in various elements of our UI.
1234567
- Because this is only for display purposes, you can freely change it without breaking any other models or content.
labelField
Used by the visual editor to make it easier to navigate between and within pages. Whenever a content item name is shown in the editor, the value of the field in that content item will be used to label the item.
12345678910111213
name
The unique name of the model, which is often the ID for API CMSs. This is not a title or label, which are typically used only for display purposes.
123456789
- The model's name is used whenever an instance of this model is stored or this model is referenced anywhere, and thus it typically should not be changed. When you have control over the name of the model, we suggest using PascalCase (e.g.
CaseStudySection). - If using Git CMS, the model name is included in all content items via their
typeattribute, which is automatically set by the visual editor when the content is stored. In other words, the model name is the content type.
readOnly
Prevents document's fields from being edited.
readOnly property prevented documents for the content model from being created and deleted but did not prevent document fields from being edited. This is useful for global, singleton models, which are typically used to affect globally-shared content on the site, such as settings, styles, and default SEO values.
Fields can override this value for themselves using their own readOnly property.
For example:
12345678910111213141516
1234567
canDelete
Allows deletion of the documents for the content model. Requires config version 0.7.0 or higher.
1234567
singleInstance
Used to specify that a model is a singleton. When set to true, only one instance can ever be created.
1234567
type
The type of the model. Learn more about model types.
1234567
pageanddatamust also specify thefilePathproperty.pagemust specify theurlPathproperty.- Setting
pagewill enable the ability to create new pages in the visual editor. To ensure this works properly, you must do both of the following:
urlPath
The urlPath setting tells the visual editor how to build the sitemap by providing a path for all of a model's page.
12345678
- Values inside curly braces are interpolated to resolve individual page properties. For example, if the
urlPathwere set to/blog/{id}, the visual editor will retrieve all documents of the model and use each one'sidproperty to build an array of paths for the sitemap — e.g.["/blog/1", "/blog/2", "..."]. For singleton models (models with only a single document), the
urlPathcan be hard-coded to explicitly what the path should be. Example for a model that holds a single blog feed page:12345678