Pages, Page Types, Templates
Pages
A Page in React Bricks represent a unit of content.
It corresponds to a website page or a blog post, but can also store content fragments reusable across different pages.
A page has content, type, slug, name, author, meta values, statuses (visibility, lock, approval phase, etc.), tags, and creation date.
The content of a page is an array of content blocks. Each block has an id
, a type
(referencing the corresponding brick name) and props
to pass to the brick’s component.
A page can also be based on a Page Template. In this case, its content is more structured, as content blocks belong to one of the Template’s Slots.
Page Types
Developer can define multiple Page Types in code through the pageTypes
configuration. In the starter templates, you can edit Page Types in the pageTypes.ts
file.
Each Page Type has:
name
(required): A unique string representing the page typepluralName
(required): Used by the content administration interfacedefaultLocked
: Boolean, default falsedefaultStatus
:types.PageStatus.Published
ortypes.PageStatus.Draft
getDefaultContent
: A function returning the default content (array of brick’s names, stories or full content)isEntity
: Boolean, default false. If true, pages of this type appear in the “Entities” tab (useful for reusable fragments like Header, Footer, etc.).allowedBlockTypes
: Array of allowed bricks. If not provided, all bricks are allowed.getExternalData
: Async function (receiving thepage
object as an argument) that resolves to an object, fetching data from an external API. The returned data is available in theexternalData
object on the page and can be consumed directly (usePageValues
) or from a single brick via themapExternalDataToProps
function in the brick’sschema
.getDefaultMeta
: Function (receiving thepage
object andexternalData
object as arguments) to return default meta values for a new page (e.g. set Schema.org data on a product from a headless commerce structured data).template
: An array of Slots defining a page template (see next section).
Page Template
Sometimes you want to restrict editors’ freedom when composing a page. You might want fixed sections, blocks that can’t be removed, areas where editors can use only a subset of bricks, or even non-editable sections. Templates serve this purpose.
A template
is an array of slots
, where each slot has these properties:
slotName
(required): The name of the slot, unique within this pageTypelabel
(required): A label displayed in the editing interfaceallowedBlockTypes
: Array of strings with the names of allowed bricksgetDefaultContent
: Function that returns the default content for the slot, with the same signature asgetDefaultContent
at pageType levelmin
: Minimum number of blocks (applied when there is only one type inallowedBlockTypes
)max
: maximum number of blockseditable
: if false the slot is not editable at all