Siirry sisältöön

Esikatselu

Gutenberg mahdollistaa lohkojen esikatselun, kun viet hiiren lohkon päälle kiinteässä lohkojen lisäysvalikossa. Jos haluat ottaa käyttöön Blockstudio-ohjelmalla tehtyjen lohkojen esikatselut, aseta avaimen example arvoksi tyhjä objekti.

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

Mukautetut tiedot

Avaimeen example voi antaa myös rakenteisia tietoja, jotta mukautetut attribuutit renderöidään oikein.

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

Jos lohkosi käyttää InnerBlocks-ominaisuutta, voit antaa InnerBlocksille mallin.

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
}