I am following the Volto-hands-on training step by step and I found out the problem is related to the config.js file.(Checked using console.log in config.js and got error in the console after doing inspect .
It seems that you put some stuff into the wrong file, i guess ? Because for me its working. Let me show you where i put the stuff in. I am using Plone 6.1 with Volto 18. We will create a Custom Block called "Slider", just like in the Guide.
At the end of this long post, i added a screenshot (Screenshot 5) with all files etc.
I called my Project just "Demo Plone" in cookieplone, so the project files are in /frontend/packages/volto-demo-plone/.
So we need three steps:
Create the Block
Prepare import paths for Block-Views
Register Block in Blocks settings
Create the Block
Note: All files and paths are in /frontend/packages/volto-demo-plone/
Create the Slider-Block
Now we create the View for our Block and also a View for the Edit-Mode. To keep it simple, we just print out a text saying we are in View-Mode or Edit-Mode.
Create a folder "Blocks" in /src/components/
Create a folder "Slider" /src/components/Blocks/
In the new "Slider" folder, you cerate two files with following content:
Edit.jsx and
View.jsx
Edit.jsx:
import React from "react";
const Edit = (props) => {
return <div>I'm the Slider edit component!</div>;
};
export default Edit;
View.jsx:
import React from "react";
const View = (props) => {
return <div>I'm the Slider view component!</div>;
};
export default View;
Prepare import paths for Block-Views
To keep the paths for importing components clean, we use index files in Volto so that we have a central location from which we can import components into our project without having to enter the full path each time.
Create a file called index.js in /src/components/ with follwoing content:
index.js:
import SliderBlockEdit from "./Blocks/Slider/Edit";
import SliderBlockView from "./Blocks/Slider/View";
export { SliderBlockEdit, SliderBlockView };
Note: If we want to import this now, we can just do import { SliderBlockView, SliderBlockEdit } from "./components/";
instead of typing the full path ./components/Blocks/Slider
Warning: There is also a index.js in /src/ which is a different index.js than the one we created! (See Screenshot 1)
So finally we have our new Block You may need to restart the frontend, so the development server detects the new files. Also check if you saved the files.