Page Templates
Introduction
Page templates allow to configure a set of predefined slots for a pageType.
Each slot is a fixed part of the page with a name
, label
, min
and max
number of blocks and allowedBricks
. It can be editable
or not and have default content, defined by the getDefaultContent
function.
Templates are ideal for pages like e-commerce product details, where you have fixed sections that may fetch data from external APIs, as well as more flexible areas for content editors to customize.
Properties
Each template object has the following shape:
Properties definition
Property | Definition |
---|---|
slotName | The name for the slot, unique for the pageType. |
label | Label for the slot showed in the editing interface. |
min | Minimum number of bricks |
max | Maximum number of bricks |
allowedBlockTypes | The bricks allowed in this slot |
excludedBlockTypes | The bricks not allowed in this slot |
getDefaultContent | Function that returns the default content for a new page of this slot. If the function returns a string for a block, it should be a brick name: the default content for that brick will be used to populate the block. In case of an IBrickStory, a particular story of the brick is used to populate the block. In case of IContentBlock you can provide the exact content block (id, type and props). |
Usage example
Rendering single Slots
Once you define slots on a page template, you can also render single slots instead of a full page. Rather than using <PageViewer page={page}>
, you can render a single slot using the <Slot>
component: