I can't use slice machine yet unfortunately (gatsby user), but I really want to start taking advantage of some of the slices in the library that slice machine uses (FAQs for example)
Prismic already has some pre-defined slices, can we add the 'new' ones from slice machine into the standard prismic slice library
You can grab the slice models from the library on itâs github.
All the slices are there to use.
Though I agree this would be cool and was something we discussed. We are also working another solution that might be just as easy as this. Iâll update you here once I know more.
The library manifest is kept in an sm.json file, at the root of the project. If you want all slice models, you would have to copy the âslicesâ object and manually add it to the âchoicesâ key of your Prismic custom type.
When I create new custom types, I create them in the Prismic Web Interface and then copy all the JSON in the âJson Editorâ tab, and paste that into a new file in my code project under /content_types/whatever.json
These are two scenarios I want to use:
A) Starting a new slice from scratch
B) Duplicating a provided library slice to make my own custom slice
Letâs take Duplicating a Slice to customise my own local version:
In my project I create a new slice:
$ npx prismic-cli sm --create-slice #==> Lets say we created âCallActionâ
Replace the contents of my new Slice with the contents of the library provided CallToAction.
Login to Prismic and open content type that suports the new Slice.
At this stage it looks like I need to create the fields by dragging them in with the UI, but this seems wasteful of time and prone to variation and hence inacuracy.
Whatâs the best way to import the JSON into Prismic?
This is a good question, and youâre on the right track. To import the JSON, simply copy it from /model.json. Then, in the JSON editor in the custom type builder, in âchoicesâ, create a new key with the snake_cased name for your slice, and paste in the JSON from /model.json as the value.
Note: the name of your slice in Prismic must be the snake_cased version of the PascalCased name in your code in order for the slice-zone component to properly match them.