Hi @jimmy.fagerberg,
You should be able to preview any content, including unpublished documents that may be "supplementary" such as navigation links. To accomplish this, your Link Resolver and withPrismicUnpublishedPreview HOC should be setup accordingly.
(When I mention "navigation document", I mean any document you are using to manage your navbar.)
Depending on how you query for your navigation documents, you may also need to run useMergePrismicPreviewData (this isn't documented on GitHub but will be included in the updated documentation on prismic.io).
Your Link Resolver could be set up like this. See the navigation case.
// src/linkResolver.js
exports.linkResolver = (doc) => {
switch (doc.type) {
case 'page': {
return `/${doc.uid}`
}
// Note that if a Navigation document is previewed, we will be sent to the
// homepage. We do this since a navigation document doesn't map directly
// to a page on the site. Instead, it is used throughout the site, such
// as in a shared Layout component.
case 'navigation': {
return '/'
}
default: {
return '/'
}
}
}
Since previewing a navigation document will send editors to the homepage, there is no need to include it withPrismicUnpublishedPreviews. That HOC is designed for custom types that have dedicated pages/templates within your site.
If you use Gatsby's useStaticQuery or <StaticQuery> to fetch your navigation links, you will need to ensure the query include _previewable and uses useMergePrismicPreviewData immediately after getting the result.
import { graphql, useStaticQuery } from 'gatsby'
import { useMergePrismicPreviewData } from 'gatsby-plugin-prismic-previews'
const NavBar = () => {
const rawData = useStaticQuery(graphql`
prismicNavigation {
_previewable
data {
# Your fields...
}
}
`)
const data = useMergePrismicPreviewData(rawData)
// `data` now contains previewed Navigation data!
}
Thank you for using the beta! If you have any feedback, please feel free to share it.
The official documentation is being updated to reflect gatsby-source-prismic V4 and gatsby-plugin-prismic-previews so you will see better documentation soon.