Skip to content

Commit

Permalink
Add section about using the schema during development
Browse files Browse the repository at this point in the history
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: SchemaStore/schemastore#1879
  • Loading branch information
mkaz committed Oct 21, 2021
1 parent 6452d44 commit f714827
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/reference-guides/block-api/block-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit f714827

Please sign in to comment.