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]
本文作者
ninohx96
创建/发布于
Published On
更新/发布于
Updated On
许可协议
CC BY-NC-SA 4.0

转载或引用本文时请遵守“署名-非商业性使用-相同方式共享 4.0 国际”许可协议,注明出处、不得用于商业用途!分发衍生作品时必须采用相同的许可协议。