RD Pennell
Community Engineer at Sanity.io
RD is located at Richmond, CA
Add a count of documents to your Structure Builder panes
This schema is for an older version of Sanity Studio (v2), which is deprecated.
Learn how to migrate to the new Studio v3 →import S from '@sanity/desk-tool/structure-builder';
import documentStore from 'part:@sanity/base/datastore/document';
import { map } from 'rxjs/operators';
export default () => documentStore.listenQuery(`count(*[_type == 'movie'])`).pipe(
map((count) =>
S.list()
.title('Movie Database Example')
.items([
S.documentTypeListItem('movie').title(`Movies (${count})`),
...S.documentTypeListItems().filter(
(listItem) => !['movie'].includes(listItem.getId())
),
])
)
);
Within the Community Slack, we're often asked how to show the count of a given document type within a custom Desk structure. The documentStore
and rxjs
allow us to display a count inside of our title that updates in real time.
Community Engineer at Sanity.io
This will allow you to display an array of references as a checklist from which you can multi-select.
Go to V3 version of Display an array of references as a checklistPopulate your list options in a string schema using an external API
Go to Asynchronous List Options ComponentUse the renderDefault function to easily control your available array options.
Go to Filter Array Options Based on the Current User RoleFetch an image from a URL and upload to Sanity it via the JS Client
Go to Upload An Image From a URL