See Sanity in action 👀 Join us for a live product demo + Q&A →

Setting Parent in Route and Query with References

1 replies
Last updated: Jan 10, 2023
I have a route “/about”, that has an
subRoutes
array of references to other routes. I’ve added “/about/team” to this array.
So now “/about” knows about the sub pages due to
subRoutes
but the sub pages them selves doesn’t know about their “parent”.
I think I need to set
parent
in the route, and query with
references(^._id)
but I feel that I miss another argument to specify that the reference only is relevant if it’s within
subRoutes
. It would otherwise give me all references, that aren’t from
subRoutes
.
Or what?
Jan 10, 2023, 7:07 PM
Is this what I am looking for?
"parent": *[_type == "route" && ^._id in subRoutes[]._ref][0]
Jan 10, 2023, 7:26 PM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Categorized in