Finding Sections to Add to a Document Using the Reference Type Schema

2 replies
Last updated: Apr 30, 2021
Hey everyone! I need some help here. My client is having a really hard time finding sections to add to a document using the reference type schema. One of the biggest improvements she would like to have is for the results to at least be alphabetized. I know there is an "option.filter" available for the reference schema but can't find any examples of how to use it. Thanks in advance for any help!
Apr 29, 2021, 7:28 PM
option.filter
will let you constrain your search, but just the filter (no projections,
order()
, etc.). I tried pulling in the documents using
client.fetch()
inside the filter function and sorting them, which works, but then applying them through
params
had no effect on the order of documents in the dropdown. I think you might need to go with a custom input component to get an alphabetized reference dropdown.
Apr 29, 2021, 9:14 PM
thanks!
Apr 30, 2021, 3:31 PM

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?