Hello,
Getting an error when running GitHub - prismicio-community/nextjs-starter-prismic-blog: Blog project with Next.js & Prismic
previewData is not returned by getStaticProps context in pages/index.tsx
export async function getStaticProps(context) {
console.log(context);
const client = createClient({ context });
let blogHome = null;
try {
blogHome = await client.getSingle("blog-home");
} catch {
// If we reach this line, it means a Blog Home document was not created
// yet. We don't need to do anything here. We will render a component on
// the page with a helpful setup message.
}
const posts = await client.getAllByType("post", {
orderings: [{ field: "my.post.date", direction: "desc" }],
});
return {
props: {
blogHome,
posts,
},
};
}
export default Home;
Priyanka
(Priyanka Maheshwari)
March 18, 2022, 11:32am
3
Hello @tenjojeremy
Welcome to the Prismic community, and thanks for reaching out to us.
What error are you getting when running the project? How did you configure Prismic in prismicio.js
file?
Thanks,
Priyanka
Hi @Priyanka ,
Thank you
I am not getting errors. The issue is that I am not getting previewData
inside the context returned by getStaticProps
in pages/index.js
My primicio.js
is the same from nextjs-sample-blog/prismicio.js at master · prismicio-community/nextjs-sample-blog · GitHub
I downloaded GitHub - prismicio-community/nextjs-sample-blog and only changed the endpoint
in sm.json
Priyanka
(Priyanka Maheshwari)
March 22, 2022, 1:35pm
5
Hello, @tenjojeremy
You should get previewData if you configure previews in your repository. Have you configured Previews in your repository?
Thanks,
Priyanka
@Priyanka
Yes. Am I missing something?
@Priyanka updating to "@prismicio /next": "^0.1.0" fixed the issue.
Thank you!