micropackage / block-loader

Automatic WordPress Gutenberg block loader based on template files
GNU General Public License v3.0
24 stars 5 forks source link

Supports JSX: true? #5

Open chasecee opened 2 years ago

chasecee commented 2 years ago

Love this tool, super helpful. I can't seem to get the InnerBlocks to work properly in my theme and I've tried just about everything. Since I don't see it, I'm wondering if Block Loader enables adding Supports JSX in the comment heading.

Right now the element gets added in the theme file when generating from ACF. But I can't actually add any innerblocks in the post editor. Am I missing something or has this feature not been added? In the screenshot you can see that an element gets added, but nothing can be dropped into the block or created within the block.

Screen Shot 2022-03-28 at 1 26 15 PM

!

jakubmikita commented 2 years ago

@chasecee it is supported and we're using it this way daily, no additional configuration params are needed.

Seems like the valid tag is: <InnerBlocks />

Can you confirm that works?

chasecee commented 2 years ago

It's not working for me on a new install with no other plugins and in default theme. Here's my blocks/hero.php template file:

image

Also maybe helpful to know, here is the beginning of my functions.php:

image

If I don't have the require vendor/autoload.php, I get a PHP error. Is this common knowledge to include this? Wondering why it's not included in the docs.

Thanks for your help!

joshuafredrickson commented 6 months ago

@chasecee is correct. JSX doesn't work out of the box.

I was able to get it working by using the block-params filter like so:

add_filter('micropackage/block-loader/block-params', function ($params) {
    if (in_array($params['slug'], ['carousel', 'accordion'])) {
        $params['supports']['jsx'] = true;
    }

    return $params;
});