Gutenberg extensions for o2 theme
This code is developed in the calypso monorepo at https://github.com/Automattic/wp-calypso/tree/trunk/apps/o2-blocks.
Your extension should follow this structure:
.
βββ src/blockname/
βββ editor.js β script loaded only in the editor
βββ editor.scss β styles loaded only in the editor
βββ view.js β script loaded in the editor and theme
βββ view.scss β styles loaded in the editor and theme
If your block depends on another block, place them all in extensions folder:
.
βββ blockname/
βββ sub-blockname/
Block naming conventions
Blocks are registered by providing a name and settings like this:
registerBlockType( 'prefix/name', {
/* settings */
} );
Building
To build bundle in apps/o2-blocks/dist, run:
# Builds files and places them in `apps/o2-blocks/dist`
cd apps/o2-blocks
yarn build
Development environment
- Run commands from this app directory:
cd apps/o2-blocks - Build
o2-blocksby runningyarn build --watch - Run
yarn wp-env startto start a local dockerized WordPress instance that will automatically use and activateo2-blocksas a plugin.
If you are not well-acquainted with wp-env yet, read this article first.