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

Feature : Add support for building blocks in theme #512

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

nani-samireddy
Copy link
Member

@nani-samireddy nani-samireddy commented Jan 17, 2025

Description

This PR adds support for building blocks using npm commands, Blocks automatic registration and excluding blocks from registering.

Technical Details

The following commands are added for the blocks and uses wp-scripts internally.

  • npm run create:block: To create a new block it accepts all the parameters that @wordpress/create-block take.
  • npm run build:blocks: To generate the build files for blocks.
  • npm run build:block-manifest: To generate the blocks-manifest.php file at /assets/build/blocks/blocks-manifest.php This will be used to register the blocks metadata collection.
  • npm run start:blocks: To start the dev server for blocks and will build the blocks whenever any changes are made in the block files.

File structure

  • All the blocks will be placed inside the /assets/src/blocks/ folder. Build files for the respective blocks will be in /assets/build/blocks/

Automatic Block Registration

  • All the blocks in the assets/build/blocks/ are registered automatically using PHP script.

Excluding blocks

  • By default all the blocks are registered. To exclude any block from registering, Update the block folder name with an _ prefix.

Documentation

  • All the required documentation about the building blocks support is added in the docs/blocks-guide.md file.

Checklist

  • New block can be added with a npm script.
  • New blocks are registered automatically.
  • Should be able to exclude any block from build or registration.
  • Appropriate documentation has been added to /docs

Screenshots

add.building.blocks.support.to.the.theme.mov

To-do

Fixes/Covers issue

#510

@nani-samireddy nani-samireddy self-assigned this Jan 18, 2025
@nani-samireddy nani-samireddy linked an issue Jan 20, 2025 that may be closed by this pull request
8 tasks
@nani-samireddy nani-samireddy marked this pull request as ready for review January 20, 2025 06:01
@nani-samireddy nani-samireddy added the [Type] Enhancement Enhancement done or needs to be done for an existing feature label Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement Enhancement done or needs to be done for an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for building blocks in theme
1 participant