Lewati ke konten

Pratinjau

Gutenberg memungkinkan pratinjau blok saat Anda mengarahkan kursor ke blok di penyisip blok tetap. Untuk mengaktifkan pratinjau blok yang dibuat dengan Blockstudio, cukup tetapkan kunci example ke objek kosong.

JSON
{
  "name": "blockstudio/native",
  "title": "Native Block",
  "category": "text",
  "icon": "star-filled",
  "description": "Native Blockstudio block.",
  "example": {},
  "blockstudio": true
}

Data Kustom

Anda juga dapat memberikan data terstruktur di kunci example agar atribut khusus dirender dengan benar.

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

Jika blok Anda bergantung pada InnerBlocks, Anda dapat menyediakan templat untuk 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
}