Voorbeeld
Gutenberg maakt het mogelijk blokken vooraf te bekijken door er in de vaste blokinvoeger met de muis overheen te gaan. Stel de sleutel example in op een leeg object om voorbeelden in te schakelen voor blokken die met Blockstudio zijn gemaakt.
JSON
{
"name": "blockstudio/native",
"title": "Native Block",
"category": "text",
"icon": "star-filled",
"description": "Native Blockstudio block.",
"example": {},
"blockstudio": true
}
Aangepaste gegevens
Je kunt ook gestructureerde gegevens opgeven in de sleutel example, zodat aangepaste attributen correct worden gerenderd.
JSON
{
"name": "blockstudio/native",
"title": "Native Block",
"category": "text",
"icon": "star-filled",
"description": "Native Blockstudio block.",
"example": {
"attributes": {
"title": "This title will be shown in the preview"
}
},
"blockstudio": true
}
PHP
PHP
<h1><?php echo $a['title']; ?></h1>
Twig
Twig
<h1>{{ a.title }}</h1>
InnerBlocks
Als je blok afhankelijk is van InnerBlocks, kun je een template voor de InnerBlocks opgeven.
JSON
{
"name": "blockstudio/native",
"title": "Native Block",
"category": "text",
"icon": "star-filled",
"description": "Native Blockstudio block.",
"example": {
"innerBlocks": [
{
"name": "core/paragraph",
"attributes": {
"content": "This is the default InnerBlocks block."
}
}
]
},
"blockstudio": true
}