Skip to content

Commit

Permalink
Docs: Add instructions on how to add new core blocks to block-library (
Browse files Browse the repository at this point in the history
…#38868)

* Add additional info on how to add new core blocks to block-library

* Format the README
  • Loading branch information
michalczaplinski authored Feb 19, 2022
1 parent 876a955 commit 1d7fa7a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/block-library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,20 @@ This is an individual package that's part of the Gutenberg project. The project

To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).

### Adding new blocks

⚠️ Adding new blocks to this package **requires** additional steps!

1. Do not forget to register your new block in the [`index.js`](https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/index.js) file of this package. For example, if you were to add a new core block called `core/blinking-paragraph`, you would have to add something like:

```js
// packages/block-library/src/index.js
import * as blinkingParagraph from './blinking-paragraph';

// Then add `blinkingParagraph` to either `__experimentalGetCoreBlocks()`
// or `__experimentalRegisterExperimentalCoreBlocks()`
```

2. Register your block in the `gutenberg_reregister_core_block_types()` function of the [`lib/blocks.php`](https://github.com/WordPress/gutenberg/blob/trunk/lib/blocks.php) file. Add it to the `block_folders` array if it's a [static block](https://developer.wordpress.org/block-editor/explanations/glossary/#static-block) or to the `block_names` array if it's a [dynamic block](https://developer.wordpress.org/block-editor/explanations/glossary/#dynamic-block).

<br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>

0 comments on commit 1d7fa7a

Please sign in to comment.