Aperçu
Gutenberg permet de prévisualiser les blocs en les survolant dans l’outil fixe d’insertion de blocs. Pour activer l’aperçu des blocs créés avec Blockstudio, il suffit de définir la clé example sur un objet vide.
JSON
{
"name": "blockstudio/native",
"title": "Native Block",
"category": "text",
"icon": "star-filled",
"description": "Native Blockstudio block.",
"example": {},
"blockstudio": true
}
Données personnalisées
Vous pouvez également fournir des données structurées dans la clé example afin que tous les attributs personnalisés soient correctement rendus.
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
Si votre bloc dépend de InnerBlocks, vous pouvez fournir un modèle pour les blocs internes.
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
}