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

Setting Up Studio Preview to Take Multiple URLs

12 replies
Last updated: Oct 3, 2022
Im using preview inside the studio, but im wondering how i could set up to let it take multiple urls?
Oct 3, 2022, 12:41 PM
Lets say i have another url with
<https://ignite-gnist-toolbox.vercel.app/about>
. how can i add this to the preview?
Oct 3, 2022, 12:42 PM
You can switch based on the document type. šŸ™‚
Oct 3, 2022, 12:46 PM
If the type is foo, you return this URL, if the type is bar, you return this URL, etc.
Oct 3, 2022, 12:46 PM
or could you explain with test code?
Oct 3, 2022, 12:49 PM
if (document.type === 'foo') {
  return BASE_URL + '/path/to/page'
}

if (document.type === 'bar') {
  return BASE_URL + '/page/to/other/page'
}
Oct 3, 2022, 12:50 PM
ahaaa, Thanks so much!
Oct 3, 2022, 12:50 PM
export default function resolveProductionUrl(document) {
  if (document.type === 'tools') {
    return `<https://ignite-gnist-toolbox.vercel.app/tools/${document.slug.current}>`;
  }
  
  if (document.type === 'about') {
    return `<https://ignite-gnist-toolbox.vercel.app/about>`
  }

}
Oct 3, 2022, 12:57 PM
for some reason its disabled?
Oct 3, 2022, 12:58 PM
user F
tagging you in case you dont see my new messages
Oct 3, 2022, 1:00 PM
type was written wrong šŸ˜›
_type
Oct 3, 2022, 1:07 PM
Ah yes, makes sense. My bad. šŸ™‚
Oct 3, 2022, 1:16 PM

Sanityā€“ build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?