@wordpress/create-block-interactive-template 2.42.0 → 2.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/index.js +3 -2
- package/package.json +2 -2
- package/plugin-templates/$slug.php.mustache +5 -5
package/README.md
CHANGED
|
@@ -12,6 +12,38 @@ npx @wordpress/create-block --template @wordpress/create-block-interactive-templ
|
|
|
12
12
|
|
|
13
13
|
It requires at least WordPress 6.5 or Gutenberg 17.7.
|
|
14
14
|
|
|
15
|
+
## Variants
|
|
16
|
+
|
|
17
|
+
This template exposes three variants. Use the `--variant` flag to select one:
|
|
18
|
+
|
|
19
|
+
### `default`
|
|
20
|
+
|
|
21
|
+
The standard interactive block scaffold. Uses the Interactivity API to demonstrate reactive state, context, and DOM event handling.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx @wordpress/create-block --template @wordpress/create-block-interactive-template --variant default
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This is also the variant used when no `--variant` flag is provided.
|
|
28
|
+
|
|
29
|
+
### `typescript`
|
|
30
|
+
|
|
31
|
+
Same as `default` but the view script (`view.ts`) is written in TypeScript, with fully typed store state and context.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx @wordpress/create-block --template @wordpress/create-block-interactive-template --variant typescript
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### `client-side-navigation`
|
|
38
|
+
|
|
39
|
+
Demonstrates client-side navigation powered by `@wordpress/interactivity-router`. The block renders a quote navigator whose Prev / Next links swap page content without a full reload. A client-side stopwatch running outside the router region proves that no full page reload occurred.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npx @wordpress/create-block --template @wordpress/create-block-interactive-template --variant client-side-navigation
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This variant adds `@wordpress/interactivity-router` as an additional npm dependency.
|
|
46
|
+
|
|
15
47
|
## Contributing to this package
|
|
16
48
|
|
|
17
49
|
This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.
|
package/index.js
CHANGED
|
@@ -18,9 +18,10 @@ module.exports = {
|
|
|
18
18
|
viewScriptModule: 'file:./view.js',
|
|
19
19
|
render: 'file:./render.php',
|
|
20
20
|
example: {},
|
|
21
|
+
folderName: './src/$slug',
|
|
21
22
|
customScripts: {
|
|
22
|
-
build: 'wp-scripts build --experimental-modules',
|
|
23
|
-
start: 'wp-scripts start --experimental-modules',
|
|
23
|
+
build: 'wp-scripts build --experimental-modules --blocks-manifest',
|
|
24
|
+
start: 'wp-scripts start --experimental-modules --blocks-manifest',
|
|
24
25
|
},
|
|
25
26
|
},
|
|
26
27
|
variants: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/create-block-interactive-template",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.43.0",
|
|
4
4
|
"description": "Template for @wordpress/create-block to create interactive blocks with the Interactivity API.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "2cea90674d11aa521ec3f71652fb3a6a4c383969"
|
|
30
30
|
}
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
38
38
|
exit; // Exit if accessed directly.
|
|
39
39
|
}
|
|
40
|
-
|
|
41
40
|
/**
|
|
42
|
-
* Registers the block
|
|
43
|
-
* Behind the scenes, it registers also all assets so they can be enqueued
|
|
41
|
+
* Registers the block(s) metadata from the `blocks-manifest.php` and registers the block type(s)
|
|
42
|
+
* based on the registered block metadata. Behind the scenes, it registers also all assets so they can be enqueued
|
|
44
43
|
* through the block editor in the corresponding context.
|
|
45
44
|
*
|
|
46
|
-
* @see https://
|
|
45
|
+
* @see https://make.wordpress.org/core/2025/03/13/more-efficient-block-type-registration-in-6-8/
|
|
46
|
+
* @see https://make.wordpress.org/core/2024/10/17/new-block-type-registration-apis-to-improve-performance-in-wordpress-6-7/
|
|
47
47
|
*/
|
|
48
48
|
function {{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init() {
|
|
49
|
-
|
|
49
|
+
wp_register_block_types_from_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
|
|
50
50
|
}
|
|
51
51
|
add_action( 'init', '{{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init' );
|