Sanity Groq Example
👀 A typical Sanity Groq Example:
lang-GROQ
*[_type == "category" && defined(slug.current)]{
"id": _id,
"slug": slug.current,
title,
"postCount": count(*[_type == "post" && defined(slug.current) && references(^._id)]),
"posts": *[_type == "post" && defined(slug.current) && references(^._id)] {
"slug": slug.current,
title,
}
} | order(postCount desc)[postCount > 0]
ref:
Sanity Groq Example
https://blog.ninoh.cc/snippets/sanity-groq-eg[Copy]转载或引用本文时请遵守“署名-非商业性使用-相同方式共享 4.0 国际”许可协议,注明出处、不得用于商业用途!分发衍生作品时必须采用相同的许可协议。