Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Document specific content previews

By Fershad Irani

Document specific content previews

./resolveProductionUrl.js

// Show previews for only the two document types listed below.

export default function resolveProductionUrl(document) {
  // Use this preview URL for news releases
  if (document._type === 'newsRelease') {
    return `https://my-site.com/news/${document.slug.current}`
  }
  
  // Use this preview URL for legal documents
  if (document._type === 'legal') {
    return `https://my-site.com/legal/${document.slug.current}`
  }
}

This snippet extends on the instructions provided in the Preview content on site guide.

It demonstrates how to use different page content previews for different page type. Taking this approach will also hide the page content preview menu option on pages that are not explicitly set.

Contributor