Forhåndsvisning
Gutenberg gør det muligt at forhåndsvise blokke, når du holder markøren over en blok i den faste blokindsætter. Du kan aktivere forhåndsvisning af blokke, der er oprettet med Blockstudio, ved blot at sætte nøglen example til et tomt objekt.
JSON
{
"name": "blockstudio/native",
"title": "Native Block",
"category": "text",
"icon": "star-filled",
"description": "Native Blockstudio block.",
"example": {},
"blockstudio": true
}
Brugerdefinerede data
Det er også muligt at angive strukturerede data i nøglen example, så eventuelle brugerdefinerede attributter gengives korrekt.
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
Hvis din blok afhænger af InnerBlocks, kan du angive en skabelon til 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
}