Zum Inhalt springen

Vorschau

Gutenberg ermöglicht Vorschauen von Blöcken, wenn du im fixierten Block-Inserter mit der Maus über einen Block fährst. Um die Vorschau von Blöcken zu aktivieren, die mit Blockstudio erstellt wurden, setze einfach den Schlüssel example auf ein leeres Objekt.

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

Benutzerdefinierte Daten

Du kannst auch strukturierte Daten im Schlüssel example angeben, damit alle benutzerdefinierten Attribute korrekt gerendert werden.

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

Wenn dein Block auf InnerBlocks basiert, kannst du eine Vorlage für InnerBlocks angeben.

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
}