I have successfully added predesigned slices from Slice Machine to my custom types and included them in my page. However, I'm encountering an issue where these slices are not visible in the preview mode, neither on localhost nor when the application is deployed. I'm wondering if there is any specific configuration I need to perform before using these slices. Below is the code snippet from my _app.js file. I'm using Next.js.
pages/_app.js
import { PrismicPreview } from "@prismicio/next";
import { repositoryName } from "@/prismicio";
export default function App({ Component, pageProps }) {
<script
async
defer
src="repo_link"
></script>;
return (
<PrismicPreview repositoryName={repositoryName}>
<Component {...pageProps} />
</PrismicPreview>
);
}
pages/index.js
import { SliceZone } from "@prismicio/react";
import Head from "next/head";
import { createClient } from "../prismicio";
import { components } from "../slices/";
export default function Home({ page }) {
return (
<div>
<Head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main>
<SliceZone slices={page.data.body} components={components} />
</main>
</div>
);
}
export async function getStaticProps({ locale, previewData }) {
const client = createClient({ previewData });
const page = await client.getByUID("page", "home", {
lang: locale,
});
return {
props: {
page,
},
};
}