Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Create Block]: Add ability to pass a slug for the block name #43235

Open
ryanwelcher opened this issue Aug 15, 2022 · 3 comments
Open

[Create Block]: Add ability to pass a slug for the block name #43235

ryanwelcher opened this issue Aug 15, 2022 · 3 comments
Assignees
Labels
Developer Experience Ideas about improving block and theme developer experience [Package] Create Block /packages/create-block [Type] Enhancement A suggestion for improvement.

Comments

@ryanwelcher
Copy link
Contributor

ryanwelcher commented Aug 15, 2022

What problem does this address?

Currently, when scaffolding a block with the @wordpress/create-block package, we can pass a slug to define the name of the plugin, which is also used as the name of the block. This was brought up in #41642 (comment)

npx @wordpress/create-block my-awesome-plugin

The command above would generate a plugin called 'my-awesome-plugin` with a block of the same name. There are many times that the name of the plugin will be different than the block.

What is your proposed solution?

Introduce a new CLI parameter called --block-name to allow the command to function as follows:

npx @wordpress/create-block my-awesome-plugin --block-name custom-block
@ryanwelcher ryanwelcher added [Package] Create Block /packages/create-block Developer Experience Ideas about improving block and theme developer experience labels Aug 15, 2022
@ryanwelcher
Copy link
Contributor Author

ryanwelcher commented Aug 15, 2022

Now that #41642 is merged, this parameter could be used to pass a series of names to allow scaffolding of multiple blocks at once

npx @wordpress/create-block --no-plugin --block-name custom-block-one,custom-block-two

@ryanwelcher ryanwelcher self-assigned this Aug 15, 2022
@ryanwelcher ryanwelcher added the [Type] Enhancement A suggestion for improvement. label Aug 15, 2022
@dgwyer
Copy link
Contributor

dgwyer commented Aug 22, 2022

Now that #41642 is merged, this parameter could be used to pass a series of names to allow scaffolding of multiple blocks at once

100% yes! I'm currently doing exactly this in a custom script I created. But I'd love to see it added as part of the @wordpress/create-block core script.

e.g. To create multiple blocks:

npx create-wp-block todo-list -b block1 block2 block3

https://github.com/dgwyer/create-wp-block

@gziolo
Copy link
Member

gziolo commented Sep 15, 2022

I’m all in for adding support for multiple blocks. It might be quite challenging to achieve in the quick mode because there are a few CLI args that should differ between blocks:

https://github.com/WordPress/gutenberg/blob/a3c753d28ddb0972311e2da0136277626bdf832e/packages/create-block/lib/index.js#L40L50

namespace is the only CLI argument that we want to share and maybe category but slug, title, and short-desc should definitely differ between blocks and even often with the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer Experience Ideas about improving block and theme developer experience [Package] Create Block /packages/create-block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants