Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block API: Improve how blocks assets are versioned #33075

Merged
merged 4 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/reference-guides/block-api/block-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Starting in WordPress 5.8 release, we encourage using the `block.json` metadata
"icon": "star",
"description": "Shows warning, error or success notices…",
"keywords": [ "alert", "message" ],
"version": "1.0.3",
"textdomain": "my-plugin",
"attributes": {
"message": {
Expand Down Expand Up @@ -248,6 +249,20 @@ This is a short description for your block, which can be translated with our tra

Sometimes a block could have aliases that help users discover it while searching. For example, an image block could also want to be discovered by photo. You can do so by providing an array of unlimited terms (which are translated).

### Version

- Type: `string`
- Optional
- Localized: No
- Property: `version`
- Since: `5.8.0`

```json
{ "version": "1.0.3" }
```

The current version number of the block, such as 1.0 or 1.0.3. It's similar to how plugins are versioned. This field might be used with block assets to control cache invalidation, and when the block author omits it, then the current version of WordPress is used instead.
gziolo marked this conversation as resolved.
Show resolved Hide resolved

### Text Domain

- Type: `string`
Expand Down
1 change: 1 addition & 0 deletions packages/create-block/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Plugin scaffolded with the `esnext` template requires WordPress 5.8 now ([#33252](https://github.com/WordPress/gutenberg/pull/33252).
- Block scaffolded with the `esnext` template is now registered from `block.json` with the `register_block_type` helper ([#33252](https://github.com/WordPress/gutenberg/pull/33252)).
- Add support for the new `version` field in the `block.json` metadata file ([#33075](https://github.com/WordPress/gutenberg/pull/33075)).

## 2.3.0 (2021-04-29)

Expand Down
2 changes: 2 additions & 0 deletions packages/create-block/lib/init-block-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = async ( {
slug,
namespace,
title,
version,
description,
category,
attributes,
Expand All @@ -35,6 +36,7 @@ module.exports = async ( {
{
apiVersion,
name: namespace + '/' + slug,
version,
title,
category,
icon: dashicon,
Expand Down