a working react/php dynamic wordpress block example integrated with the Vite build process
This commit is contained in:
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
@@ -70,7 +70,7 @@ class Editor
|
||||
$data['template'] = $this->default_template();
|
||||
$data['block'] = $block;
|
||||
|
||||
echo \Roots\view("blocks.$name.$name", [
|
||||
echo \Roots\view("acf-blocks.$name.$name", [
|
||||
'data' => $data,
|
||||
'block' => $block,
|
||||
])->render();
|
||||
12
resources/views/blocks/example/block.json
Normal file
12
resources/views/blocks/example/block.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"apiVersion": 3,
|
||||
"name": "badegg/example",
|
||||
"title": "Example",
|
||||
"category": "badegg",
|
||||
"icon": "cover-image",
|
||||
"description": "This is an example of a custom Wordpress Block created using the offical method.",
|
||||
"editorScript": "example-editor-script",
|
||||
"editorStyle": "example-editor-style",
|
||||
"style": "example-style",
|
||||
"render": "resources/blocks/example/render.blade.php"
|
||||
}
|
||||
3
resources/views/blocks/example/editor.scss
Normal file
3
resources/views/blocks/example/editor.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
.block-badegg-example-editor {
|
||||
display: block;
|
||||
}
|
||||
12
resources/views/blocks/example/index.jsx
Normal file
12
resources/views/blocks/example/index.jsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import { registerBlockType } from '@wordpress/blocks';
|
||||
|
||||
registerBlockType('badegg/example', {
|
||||
apiVersion: 3, // optional in JS, primarily in block.json
|
||||
edit() {
|
||||
return (
|
||||
<section className="block-badegg-example">
|
||||
<h2>Bad Egg Block Example</h2>
|
||||
</section>
|
||||
);
|
||||
},
|
||||
});
|
||||
3
resources/views/blocks/example/render.blade.php
Normal file
3
resources/views/blocks/example/render.blade.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<section class="block-badegg-example">
|
||||
<h2>Bad Egg Example Block (Blade)</h2>
|
||||
</section>
|
||||
3
resources/views/blocks/example/style.scss
Normal file
3
resources/views/blocks/example/style.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
.block-badegg-hero {
|
||||
display: block;
|
||||
}
|
||||
Reference in New Issue
Block a user