Skip to content

bnomei/kirby3-schema

Repository files navigation

Kirby JSON Schema

Kirby 3 Kirby 4 Kirby 5 Release Checks Discord Buymecoffee

JSON Schema file for Kirby blueprints

Install

Schemastore (not yet)

Ideally, this repo's schema would be available from the Schemastore, and there would be almost zero configuration in most IDEs. But that is something the Kirby CMS team should eventually do, not me.

Download the Schema

You can clone the entire repo or download the file kirbyX-blueprints.schema.json, where X matches your intended Kirby version. Put that file inside your project or in a global space of your dev setup. Then configure your IDE to use that file to get Schema information for Kirby's blueprints.

Configure your IDE

VSCode

You will need the Red Hat VS Code YAML Extension, and then you can use the yaml.schemas setting to add your schema like this:

  "yaml.schemas": {
    "/path/to/your/schema/kirby4-blueprints.schema.json": "site/blueprints/**/*.yml"
  }

This will automatically use the schema for all blueprint files.

The extension prepends / on the path so its /~/YOUR_FOLDER/kirby3-schema/kirby4-blueprints.schema.json.

Note

thanks @tobimori and @iskrisis

PHPStorm

Clone this repo to your local machine. Open the IDE settings and search for JSON Schema. Then select Languages & Frameworks » Schemas and DTDs » JSON Schema Mappings. Click the + button at the top to add a new JSON validate configuration. Then, fill in the corresponding name, file or URL, and version.

For testing, I mapped it to my site/blueprints folder.

Sublime Text

You can use the schema in Sublime Text by cloning this repo to your local machine and setting a custom JSON schema location using this Sublime Text extension and wildcards in fileMatch schema settings (more).

Blueprint detection

Since Kirby reuses some types like file, info, pages in fields and sections the schema can not always determine which blueprint you are working on with absolute certainty. For now, I introduced a blueprint property to solve this. Use it in your file, page, user and site blueprints.

+ blueprint: site

title: My Site Blueprint

fields:
  text:
    type: text
+ blueprint: page

title: My Page Blueprint

fields:
  text:
    type: text

Disclaimer

This schema is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.

License

MIT

It is discouraged to use this schema in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.