Kirby Copilot v2.4 introduces a new way to generate blocks that finally supports custom blocks and layout fields. You could say that Kirby Copilot has become a true page builder for Kirby CMS.
Previously, Copilot could only generate blocks for Kirby's core blocks (heading, text, list, etc.). This was quite limiting, as it meant that any custom blocks defined in your Kirby project could not be generated by the AI.
With the new blocks generation process, Copilot can now generate any block type defined in your Kirby project, including custom blocks. It accomplishes this by using object generation with JSON schemas, which enables the AI to generate structured data that matches the block definitions in your project.
excludedBlocks configuration option. This allows you to fine-tune which blocks Copilot should generate content for.Copilot reads the project's block definitions, including those from plugins. If the fieldsets limits the blocks to a specific set, then only those blocks are considered for generation.
Based on these block definitions, Copilot generates a JSON schema that defines the structure of each block, including nested fields such as structure fields.
The prompt includes the JSON schema, which enforces the AI to respond with structured data that matches the schema.
The AI's response is parsed and normalized to Kirby's block structure, allowing it to be used directly in the CMS.
Depending on the block's complexity, the resulting JSON schema can become equally complex. This leads to the following caveats:
fieldsets or simplify the block definitions.layout field generation is only supported by models other than OpenAI. Gemini models are recommended for this feature.