• Resolved Guido Goluke

    (@majorlabel)


    I often write custom blocks for my block-themes, and I use the npx creation tool to do that. Because I want to include the blocks in my theme directory, and not as separate plugins, I use the ‘--no-plugin‘ option to generate the block and perform some extra steps to get the webpack automation going. I’ve wrapped this into a Bash script here.

    I use it like this: I create a ‘blocks’ directory in my theme, and in there I place the Bash-script. I then create a block with

    bash create-block.sh -a MajorLabel -n majorlabel -t "My First Block"

    Where the ‘a’ option is the author name, the ‘n’ option is the namespace (use all lowercaps and no spaces) and ‘t’ is the block title (Remember to surround in double quotes).

    It will generate a directory which you can then change into and perform npm start to get busy developing. All you need to do is include the index.php file in the block directory in your functions.php file, which you could also do with

    foreach ( glob( __DIR__ . '/blocks/*/index.php' ) as $file ) {
        require_once $file;
    }
    • This topic was modified 1 year, 4 months ago by Guido Goluke.
    • This topic was modified 1 year, 4 months ago by Guido Goluke.
    • This topic was modified 1 year, 4 months ago by Guido Goluke.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bash script for creating no-plugin blocks’ is closed to new replies.