I'm practicing how to create Gutenberg blocks plugin. I use @wordpress/create-block to create a blocks plugin.
Edit: I didn't use the wp-cli scaffold as I initially stated, what I meant to write is that I used @wordpress/create-block.
The scaffold is made to only have one block on it, so, if you want more than one block you have to modify the structure, which is not that hard, but, I want the blocks to use block.json to register blocks with register_block_type_from_metadata(), which I achieved, but the problem is that if I use this code (register_block_type_from_metadata twice) in the main plugin's PHP file:
function blocks_boilerplate_block_init() {
register_block_type_from_metadata( __DIR__ . '/src/blocks/example');
register_block_type_from_metadata( __DIR__ . '/src/blocks/example2');
}
add_action( 'init', 'blocks_boilerplate_block_init' );
To register the blocks, the blocks get registered and they work without problems, but the Chrome console shows two errors.
Block "create-block/boilerplate-example" is already registered.
Block "create-block/guten-block-example2" is already registered.
If I use register_block_type_from_metadata() only once, the error goes away.
Any ideas on how to make the errors disappear?