🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Querying a navigation sidebar for a documentation site using a plugin in Sanity.io.

2 replies
Last updated: Apr 4, 2024
Hello. Working on a documentation site using this plugin: https://www.sanity.io/plugins/page-tree . What would a query for a navigation sidebar be? Have gotten it to work, but using reference means i have to hardcode the max depth of the tree, so i feel like a better solution would maybe be recursive. Any ideas?
*[_type == 'homePage']{
    'contentpages': *[_type == 'contentPage' && references(^._id)]{
Apr 4, 2024, 8:32 AM
GROQ can’t recursively resolve references, unfortunately.
Apr 4, 2024, 5:12 PM
Then i'll just limit the number of levels. Thanks
Apr 4, 2024, 5:12 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?