Hi folks!
Had a question I was hoping someone would know the answer to. I am trying to use separate target libraries in order to keep my slices organized. Not all slices will be used on every page so I am scoping certain slices into folders by page. The issue I am running into is that the Slice Simulator cannot find any slices outside the "slices" directory by default. If I change the code to point towards my "HomeSlices" directory like this:
import { SliceSimulator } from "@prismicio/slice-simulator-react";
import { SliceZone } from "@prismicio/react";
import state from "../.slicemachine/libraries-state.json";
import { components } from "../HomeSlices";
const SliceSimulatorPage = () => (
<SliceSimulator
sliceZone={(props) => <SliceZone {...props} components={components} />}
state={state}
/>
);
export default SliceSimulatorPage;
then the simulator will be unable to preview any slices in the default "Slices" directory. Could be that I am missing something fairly obvious here but I cannot find a ton of documentation on how to use the different target libraries other than initial setup so figured i'd just ask.
Hi Priyanka, I don't really know how to achieve this in a Nuxt 3 website.
I already added the new slices library to slicemachine.config.ts, and I can add slices there with SM, I can also import the new slices library directly in a page template, and use it through the <slize-zone> component, but I don't know how to load both slice libraries at the same time, since I want to render both. I tried to use:
So just to clarify, I can use my new library slices by importing them (it should be great to do it automatically since it's defined in the config), but i don't know how to use both libraries at the same time.
To be clear, are you looking to use both libraries simultaneously with the slice simulator? I'd like to understand your use case for using both libraries together. Can you explain more?
Sorry I thought I replied this message.
Yes, I needed to load 2 different slice libraries into de SliceZone Nuxt 3 component.
And this is how I finally achieved it:
Hope this snippet can help someone else. The target is to have a common slice library for all projects, and a custom library to fit specific project needs.