Zach Silveira was kind enough to create a video tutorial:
https://www.youtube.com/watch?v=apZwd0FqQu4&feature=youtu.be
Here are my notes as I followed along...
-
Install Docker for Mac.
-
Create & open a test folder (I used
/tmp/gutenblock-demo
). -
Copy https://gist.github.com/zackify/d8e428f93e018c3fbcce512414d02e62 to
docker-compose.yml
. -
Run
docker-compose up
.It's working if you see:
Complete! WordPress has been successfully copied to /var/www/html
-
Visit http://localhost/ and setup WordPress.
-
Install & Activate Gutenberg
-
Visit http://localhost/wp-admin/post-new.php, and now we're all caught up!
-
The video starts with http://localhost/wp-admin/post-new.php.
-
Zach uses
npm install gutenblock -g
, but I'm usingyarn global add gutenblock
. -
gutenblock init
, and now/blocks
is populated! -
cd blocks && gutenblock watch
I'm getting an error:
Module build failed: ReferenceError: Unknown plugin "/Users/eric/.config/yarn/global/node_modules/gutenblock/config/../node_modules/react-hot-loader/babel" specified in "base" at 0, attempted to resolve relative to "/private/tmp/gutenblock/blocks"
The problem is because
./blocks/node_modules/gutenblock/config/babel-options.js
should be usingrequire.resolve('react-hot-loader/babel'),
, not__dirname + '/../node_modules'...
.
I think it would be best to do the gutenblock init
before running docker-compose up
, since that folder gets mounted.
-
Ensure Gutenblock by Crossfield is Activated:
-
Continue following along with the video (editing
./blocks/src/example/edit.js
to see HMR).
You basically end up making these files:
// ./blocks/src/paragraph/block.js
const Block = {
title: 'Custom Paragraph',
icon: 'shield-alt',
category: 'common',
attributes: {
title: {
type: 'string',
},
description: {
type: 'string',
},
},
};
// ./blocks/src/paragraph/edit.js
import { RichText } from 'gutenblock-controls';
const Edit = () => (
<div>
Custom:
<RichText name="description" tagName="p" />
</div>
);
This is pretty cool! If it weren't for the duplicate terminals (one for running docker-compose up
and the other for running gutenblock watch
, this would be entirely seamless!)
This workflow can hit that sweet spot of leveraging WordPress & React both for their strengths, instead of having to dump WordPress entirely because "it's too hard to customize the editor."
👏 Fantastic work Zach! :)