Open jaymcp opened 1 month ago
We are migrating our custom blocks to v3 of the Block API to better support modern WordPress features.
To make block management easier, we should migrate away from our custom Webpack build process, and adopt wp-scripts.
To minimise the amount of configuration required, and to future-proof our blocks, we should adopt the default directory structure.
Currently, our blocks have code in several places:
/private/src/scripts/editor/blocks
/private/src/scripts/modules
/private/src/styles/blocks
/wp-content/themes/humanity-theme/includes/blocks
This is unwieldy, and makes block management frustrating. The new directory structure is greatly simplified:
source/blocks
Each block should have its own directory within source/blocks, and should contain the following files (where applicable):
block.json
edit.js
view.js
render.php
editor.scss
style.scss
index.js
save.js
We are migrating our custom blocks to v3 of the Block API to better support modern WordPress features.
To make block management easier, we should migrate away from our custom Webpack build process, and adopt wp-scripts.
To minimise the amount of configuration required, and to future-proof our blocks, we should adopt the default directory structure.
Currently, our blocks have code in several places:
/private/src/scripts/editor/blocks
contains our JS block registration, display components, and (in some cases) save components/private/src/scripts/modules
contains frontend interactivity JS modules/private/src/styles/blocks
contains our SCSS/wp-content/themes/humanity-theme/includes/blocks
contains our PHP block registration and server-side block renderer functionsThis is unwieldy, and makes block management frustrating. The new directory structure is greatly simplified:
source/blocks
contains everything!Each block should have its own directory within
source/blocks
, and should contain the following files (where applicable):block.json
- this contains the block metadata (attributes, name, description, etc)edit.js
- the display component(s)view.js
- any frontend interactivityrender.php
- server side-rendered markupeditor.scss
- styles for the block editorstyle.scss
- styles for the site editor / frontendindex.js
- block registrationsave.js
- block save component