Pāriet uz saturu

Priekšskatījums

Gutenberg ļauj priekšskatīt blokus, novietojot rādītāju virs bloka fiksētajā bloku ievietotājā. Lai iespējotu ar Blockstudio veidoto bloku priekšskatījumu, iestatiet atslēgu example uz tukšu objektu.

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

Pielāgoti dati

Atslēgā example var norādīt arī strukturētus datus, lai visi pielāgotie atribūti tiktu renderēti pareizi.

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

Ja jūsu bloks ir atkarīgs no InnerBlocks, varat norādīt InnerBlocks veidni.

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
}