Custom block preview, issue with blocks with a dash in the name

Hello. I’ve created a bunch of custom blocks, it all works great. But when I started experimenting in building my own custom block previews I ran in to trouble.

Most of my custom block-names contain a dash, and it seems I can’t have dashes in the index.js-file in my plugin. I read in this post that you can’t have dashes and should use camelCase instead but that didn’t work. I’ve also read and recreated both The Button example and the Block Factory examples but none of the example blocks created there use dashes. And there’s no mention about not using dashes in block-names when creating them that I have seen.

Am I missing something obvious? Is there a way around the dash? Or do I have to rename all of my custom blocks, and what will happen to the content generated using those blocks in that case?

Any help appreciated, thanks!

You can add a preview name in your block yaml, then use that preview name in the index.js

preview: something
1 Like

Thank you @texnixe for the superfast response! I worked like a charm :slight_smile: