Cacao Kit

Demo & Semi Documentation

Adding a block


A new block takes three steps: a blueprint in the backend, a resolver if needed, and a component in the frontend. The cards block on the about page was built this way.

In the backend

  1. Create site/blueprints/blocks/cards.yml with the fields the block needs – here a structure of cards with title, image, text, and link. Then offer the block in site/blueprints/fields/layouts.yml and site/blueprints/fields/blocks.yml, so editors can add it in the Panel.

  2. If the raw field values are not enough, add a resolver to site/config/blocks-resolver.php. cards:cards turns each image UUID into image data and each page link into a path.


In the frontend

Create app/components/Kirby/Block/Cards.vue. Nuxt registers it as KirbyBlockCards; add its lazy variant to the map in app/components/Kirby/Blocks.vue, keyed by the block type cards.

The component receives the block as its block prop. Type it with KirbyBlock from kirby-types and describe the resolved content, so the template knows what the backend sends.