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?
Lets say i have another url with
<https://ignite-gnist-toolbox.vercel.app/about>
. how can i add this to the preview?
You can switch based on the document type. πŸ™‚
If the type is foo, you return this URL, if the type is bar, you return this URL, etc.
or could you explain with test code?
if (document.type === 'foo') {
  return BASE_URL + '/path/to/page'
}

if (document.type === 'bar') {
  return BASE_URL + '/page/to/other/page'
}
ahaaa, Thanks so much!
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>`
  }

}
for some reason its disabled?
user F
tagging you in case you dont see my new messages
type was written wrong πŸ˜›
_type
Ah yes, makes sense. My bad. πŸ™‚

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?