Dear Prismic community,
I am running Prismic with GatsbyJS using gatsby-source-prismic
and gatsby-plugin-prismic-previews
, and my site is hosted on Gatsby Cloud
My Prismic toolbar is not appearing despite signed in to my repo. On top of that, I couldn’t preview the content change via localhost despite having Previews already set up on settings (doesn’t redirect me to the page after clicking the eye icon, it stops at ‘Loading Preview…’ page).
Below are my code which should responsible to the toolbar appearance.
preview.js
import * as React from 'react'
import { withPrismicPreviewResolver } from 'gatsby-plugin-prismic-previews'
import { linkResolver } from "../utils/linkResolver";
const PreviewPage = () => {
return (
<main>
<h1>Loading preview...</h1>
</main>
)
}
export default withPrismicPreviewResolver(PreviewPage, [
{
repositoryName: 'my-repo',
linkResolver: linkResolver,
},
])
linkResolver.js
module.exports = {
apiEndpoint: 'https://my-repo.cdn.prismic.io/api/v2',
repoName: "my-repo",
linkResolver: function(doc) {
if (doc.type === 'page') return "/" + doc.uid
if (doc.type === 'work') return "/work/" + doc.uid
return "/doc" + doc.uid
}
}
At the end of my {prismicPage.url}.js
...
export default withPrismicPreview(PageTemplate, [
{
repositoryName: 'my-repo',
linkResolver: linkResolver,
},
])
At the end of my 404.js
...
export default withPrismicUnpublishedPreview(
NotFoundPage,
[
{
repositoryName: 'my-repo',
linkResolver: linkResolver,
componentResolver: componentResolverFromMap({
page: PageTemplate,
work: WorkTemplate,
}),
},
],
)
I couldn't see what else I'm missing here. Let me know if there's any else info that I should provide.
Thanks in advance!
Best Regards,
Fong