Podgląd
Gutenberg umożliwia podgląd bloków po najechaniu na nie kursorem w przypiętym inserterze bloków. Aby włączyć podgląd bloków utworzonych za pomocą Blockstudio, wystarczy ustawić klucz example na pusty obiekt.
JSON
{
"name": "blockstudio/native",
"title": "Native Block",
"category": "text",
"icon": "star-filled",
"description": "Native Blockstudio block.",
"example": {},
"blockstudio": true
}
Dane niestandardowe
Można też przekazać ustrukturyzowane dane w kluczu example, aby poprawnie renderować wszelkie atrybuty własne.
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
Jeśli blok korzysta z InnerBlocks, można dostarczyć dla niego szablon InnerBlocks.
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
}