How to preview the first element in an array of references?

2 replies
Last updated: Nov 1, 2020

Hi everyone! I know that I can preview references like this:

preview: {
  select: {
    title: 'title',
    subtitle: 'referenceField.referencedTitle'
 }
}
But now I have an array of references and I would like to preview the first element in the array. This doesn't work for me:


preview: {
  select: {
    title: 'title',
    subtitle: 'referenceArrayField[0].referencedTitle'
 }
}
Is this technically possible? Thanks for any pointers
😃

Nov 1, 2020, 7:56 AM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.