-
Notifications
You must be signed in to change notification settings - Fork 35
Adding new examples
JuanMa edited this page Nov 3, 2023
·
4 revisions
This repo can create a new, blank, example using the @wordpress/create-block
package and a custom external template provided by this repository.
- Run
npm run create-example:new -- example-slug
changingexample-slug
to the name of the plugin you wish to create. - Add any additional flags that are supported by the
@wordpress/create-block
package after the--
There are currently 3 variations
supported by the custom template:
-
static
- scaffolds a plugin with a single block that renders statically by saving it's markup to the database (default) -
dynamic
- scaffolds a plugin with a single block that renders dynamically on the front end via PHP -
non-block
- scaffolds a plugin that loads a single JavaScript file. Use this variant for example such as block variations or SlotFill.
This example will create a plugin called my-great-example-{generated-hex-code}
with a single block that renders dynamically.
npm run create-example:new -- my-great-example --variant dynamic
This repo offers you a script to create a new example using any of already existing examples as a template.
- Run
npm run create-example
- Choose the example you want to use as a template for your new example
- Add a meaningful name for your example
- Add a description for your example
- Add tags for your example
The script will take care of most of the modifications needed so your new example follow the conventions of this repo.
See an example of running npm run create-example:copy
![](https://github.com/wptrainingteam/wp-block-development-examples/raw/trunk/assets/cli/create-example-copy.gif)
If you have another repo containing a plugin with an example you'd like to add as new example of this repo:
- Go to the
plugins
folder andgit clone
your repo with your example there - Go inside your project's folder
- Delete the
.git
folder - Do the proper changes to adapt your plugin to follow the conventions for this repo