I've setup the preview environment on Prismic dashboard and implementing preview script, including /404.
I created a /preview route page on Gridsome project, which do the following on mounted lifecyle:
const apiEndpoint = 'https://my-repo-name.cdn.prismic.io/api/v2';
const previewClient = Prismic.client(apiEndpoint);
const { token, documentId } = this.$route.query;
// Retrieve the correct URL for the document being previewed.
// Once fetched, redirect to the given url
previewClient.getPreviewResolver(token, documentId)
.resolve(linkResolver, '/')
.then((url) => {
// linkResolver retrieve the right URL for my article: `/blog/${formatedCategory}/${doc.uid}`
this.$router.push(url);
})
I've checked the io.prismic.preview, it seems to work using the Graphql browser. I can see my article's title changing on the graphql result.
When you preview your website, a preview cookie is generated that contains the preview token. This token can be used as a valid ref to make Prismic API queries. For any query you make on your website, make sure to check for the Preview cookie and use this preview ref in the query options if the preview cookie exists.
How can I add ref from io.prismic.preview cookie to allArticlesQuery.