SliceName in in index.js is not the same as name given in CLI

I don't know if it was because I didn't use the template for NextJS, I wanted to set it up from scratch kinda.

When I ran prismic sm --create-slice I created my slice, for instance we can call it SimpleHero.

The folder name comes out alright, and the directory structure.

What I find interesting is the name of the slice function inside index.js, it's called const MySlice. Surely it would be called const SimpleHero?

I know that the index.js at the top level @/slices directory exports the default from each of them to the correct name.

But would I be wrong in thinking that it would be clearer if the slice generated has a appropriate function name?

Open to correction on this :slight_smile:

Hi Reece,

I think this is a nice idea, this template is simply copied from the one that is present in the CLI.

I'm not sure if it will be possible to dynamically update the function name, but it shouldn't be a problem manually updating this in your project.

I'm created an RFC in the CLI's github and hopefully @marc.mcintosh and/or the rest of the Slice Machine team can look in to it:


1 Like

This is being implemented in the latest CLI updated.