๐Ÿ”ฎ Sanity Create is here. Writing is reinvented. Try now, no developer setup

Issue with desk structure previews not working on views with only one child

5 replies
Last updated: Feb 18, 2022
Using the desk structure previews (the split pane), how come the preview works in views that have multiple children, but doesn't work on views that only have one child?
Here's a screenshot of the preview not working on a view with only one document:

And it working on a view with multiple documents:

I'll share my code inside this thread
Feb 18, 2022, 6:45 PM
import S from "@sanity/desk-tool/structure-builder";
import {
  GiHouse as HomepageIcon,
  GiScrollQuill as PageIcon,
  GiNewspaper as BlogIcon,
  GiMining as ServiceIcon,
  GiPaintRoller as ProjectIcon,
} from "react-icons/gi";
import Iframe from "sanity-plugin-iframe-pane";

import resolveProductionUrl from "./resolveProductionUrl";

// ---

export const getDefaultDocumentNode = () =>
        url: (doc) => resolveProductionUrl(doc),

// ---

export default function deskStructure() {
  return S.list()
    .title("Content Manager")
        .child(() => S.documentTypeList("page")),
        .title("Blog Posts")
        .child(() => S.documentTypeList("blogPost")),
        .child(() => S.documentTypeList("project")),
        .child(() => S.documentTypeList("service")),
Feb 18, 2022, 6:45 PM
Yeah that did it User, thanks. I don't fully understand what I'm doing with some of these things ๐Ÿ˜„
Feb 18, 2022, 7:59 PM
You saved me a rapping on the knuckles from the client "why isn't the preview working" haha
Feb 18, 2022, 8:00 PM
Haha, yeah, Structure Builder is super confusing to work with!
Feb 18, 2022, 8:03 PM
Really powerful though, the clients all love it when I can get it to behave
Feb 18, 2022, 8:03 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?