πŸ‘€ See Sanity in action: Watch product demo now β†’

Is there a structure builder example where the format of each preview for the document list is modified?

4 replies
Last updated: Feb 3, 2021
Is there a structure builder example where the format of each preview for the document list is modified?
Feb 3, 2021, 3:29 AM
Example, I want to modify this to display content.title
Feb 3, 2021, 3:29 AM
If your schema looks something like this:

export default {
  name: "review",
  title: "Review",
  type: "document",
  fields: [
    {
      name: "content",
      title: "Content",
      type: "object",
      fields: [
        {
          name: 'title',
          title: 'Title',
          type: 'string',
        },
        {
          name: 'excerpt',
          title: 'Excerpt',
          type: 'string',
        }
      ]
    },
  ],
}
You can add a preview to set the title for each
review
document:

export default {
  name: "review",
  title: "Review",
  type: "document",
  fields: [
    {
      name: "content",
      title: "Content",
      type: "object",
      fields: [
        {
          name: 'title',
          title: 'Title',
          type: 'string',
        },
        {
          name: 'excerpt',
          title: 'Excerpt',
          type: 'string',
        }
      ]
    },
  ],
  preview: {
    select: {
      title: 'content.title'
    }
  }
}

Feb 3, 2021, 3:40 AM
ah brilliant, thank you. I guess I was looking in the wrong place then.
Feb 3, 2021, 3:42 AM
No problem! Thankfully, previews offer a lot of customization.
Feb 3, 2021, 3:44 AM

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.