Liigu sisu juurde

Eelvaade

Gutenberg võimaldab ploki kohal hõljutades näha selle eelvaadet fikseeritud plokivalijas. Blockstudio abil loodud plokkide eelvaate lubamiseks määra võtme example väärtuseks tühi objekt.

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

Kohandatud andmed

Samuti saab võtmes example esitada struktureeritud andmeid, et kõik kohandatud atribuudid renderdataks õigesti.

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

Kui sinu plokk sõltub väärtusest InnerBlocks, saad esitada InnerBlocksi malli.

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
}