プレビュー
Gutenbergでは、固定ブロックインサーター内でブロックにカーソルを合わせると、ブロックをプレビューできます。Blockstudioで作成したブロックのプレビューを有効にするには、exampleキーに空のオブジェクトを設定します。
JSON
{
"name": "blockstudio/native",
"title": "Native Block",
"category": "text",
"icon": "star-filled",
"description": "Native Blockstudio block.",
"example": {},
"blockstudio": true
}
カスタムデータ
exampleキーに構造化データを指定することもできます。これにより、カスタム属性が正しくレンダリングされます。
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
ブロックでInnerBlocksを使用する場合、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
}