πŸ‘€ Our most exciting product launch yet πŸš€ Join us May 8th for Sanity Connect

Listing documents of a specific schema type in a pane while also listing other document type list items in Slack.

2 replies
Last updated: Jul 17, 2023
Can I list documents of a specific schema type in a pane while also listing some other document type list items?for example: listing all 'person' documents while also having another list item 'directors' in the same list
Jul 17, 2023, 10:37 PM
Yep! If you want them mixed:
S.listItem()
        .title('Mixed List')
        .child(
          S.documentList().title('Mixed List').filter(`_type in ['person',
      'director']`)
        ),
Or if you want the directors in a subpane:

S.listItem()
        .title('List with Subpane')
        .child(async () => {
          const client = getClient({ apiVersion: '2023-07-17' });
          const documentListItems = await client
            .fetch(`*[_type == 'actor']`)
            .then(documents =>
              documents.map(document =>
                S.listItem()
                  .title(document.title)
                  .child(S.document().id(document._id).schemaType('actor'))
              )
            );
          return S.list()
            .title('List with Subpane')
            .items([S.documentTypeListItem('director'), ...documentListItems]);
        }),
Jul 17, 2023, 11:30 PM
I was asking for the second solution, I have to try it now. Thank you
Jul 17, 2023, 11:50 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?