How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

Document specific content previews

Document specific content previews

By Fershad Irani


./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

Fershad Irani

Web Sustainability & Performance Consultant

Visit Fershad Irani's profile