👀 See Sanity in action: Watch product demo now →

How to Render Items in the DeskStructure Based on Environment

2 replies
Last updated: Apr 29, 2020
I could like to conditionally render items in the deskStructure based on environment. Have been referring to the doc’s
<https://www.sanity.io/docs/studio-environment-variables>
but for whatever reason I can’t get my
.env
or
.env.development
variables to pass through? Hoping to do something like the following:
const dataset = process.env.SANITY_STUDIO_API_DATASET

export default () =&gt; {
  if(dataset == "staging"){
    S.list()
      .title('Content')
      .items([
        S.listItem()
          .title('Home Page')
          .schemaType('homePage')
          .child(S.document().schemaType('homePage')),
am I going about this the correct way?
Apr 29, 2020, 8:44 PM
Better to do it like this:
import client from “part:@sanity/base/client”

const { dataset } = client.config()
Apr 29, 2020, 8:49 PM
thanks
user Y
, appreciate it! 🌟
Apr 29, 2020, 8:51 PM

Sanity.io – build remarkable experiences at scale

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

Categorized in