From f7148278aac6366e01cd006f05260c67caf66bc2 Mon Sep 17 00:00:00 2001 From: Marcus Kazmierczak Date: Thu, 21 Oct 2021 06:23:25 -0700 Subject: [PATCH] Add section about using the schema during development Updates documentation recommending to use schema validation. A block.json JSON schema was added to the SchemaStore that allows for editors to provide additional tooltip, autocomplete, and some validation when working with a block.json file. Added in: https://github.com/SchemaStore/schemastore/pull/1879 --- docs/reference-guides/block-api/block-metadata.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/reference-guides/block-api/block-metadata.md b/docs/reference-guides/block-api/block-metadata.md index 542b8672d7f93d..fd96ccf8a87049 100644 --- a/docs/reference-guides/block-api/block-metadata.md +++ b/docs/reference-guides/block-api/block-metadata.md @@ -6,6 +6,7 @@ Starting in WordPress 5.8 release, we encourage using the `block.json` metadata ```json { + "$schema": "https://json.schemastore.org/block.json", "apiVersion": 2, "name": "my-plugin/notice", "title": "Notice", @@ -54,7 +55,13 @@ From a performance perspective, when themes support lazy loading assets, blocks Furthermore, because the [Block Type REST API Endpoint](https://developer.wordpress.org/rest-api/reference/block-types/) can only list blocks registered on the server, registering blocks server-side is recommended; using the `block.json` file simplifies this registration. -Last, but not least, the [WordPress Plugins Directory](https://wordpress.org/plugins/) can detect `block.json` files, highlight blocks included in plugins, and extract their metadata. If you wish to [submit your block(s) to the Block Directory](/docs/getting-started/tutorials/create-block/submitting-to-block-directory.md), all blocks contained in your plugin must have a `block.json` file for the Block Directory to recognize them. +The [WordPress Plugins Directory](https://wordpress.org/plugins/) can detect `block.json` files, highlight blocks included in plugins, and extract their metadata. If you wish to [submit your block(s) to the Block Directory](/docs/getting-started/tutorials/create-block/submitting-to-block-directory.md), all blocks contained in your plugin must have a `block.json` file for the Block Directory to recognize them. + +Development is improved by using a defined schema definition file. Supported editors can provide help like tooltips, autocomplete, and schema validation. To use the schema, add the following to the top of the `block.json`. + +```json +"$schema": "https://json.schemastore.org/block.json" +``` ## Block registration