File size: 1,420 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# 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:

```js
registerBlockType( 'prefix/name', {
	/* settings */
} );
```

## Building

To build bundle in `apps/o2-blocks/dist`, run:

```bash
# Builds files and places them in `apps/o2-blocks/dist`
cd apps/o2-blocks
yarn build
```

## Development environment

1. Run commands from this app directory: `cd apps/o2-blocks`
1. Build `o2-blocks` by running `yarn build --watch`
1. Run `yarn wp-env start` to start a local dockerized WordPress instance that will automatically use and activate `o2-blocks` as a plugin.

If you are not well-acquainted with `wp-env` yet, read [this](https://make.wordpress.org/core/2020/03/03/wp-env-simple-local-environments-for-wordpress/) article first.