Yes definitely! There is a :block/marker
attribute. We can say it has to have a value of “TODO”.
Here’s a complete query to try. It includes a recursive search and assumes the query is on the same page as the index. Though we can change inputs to any lower-case page name.
#+BEGIN_QUERY
{:title "Index query"
:query [:find (pull ?b [*])
:in $ ?page %
:where
[?h :block/name ?page]
[?i :block/content "Index"]
(get-children ?i ?child)
[?child :block/marker "TODO"]
[?child :block/refs ?p]
(not [?p :block/name "todo"]) ;TODO is also a page reference
[?b :block/refs ?p]
[(!= ?b ?child)] ;it's not the index itself
]
:rules [
[(get-children ?i ?child)
[?child :block/parent ?i]
]
[(get-children ?i ?child)
[?b :block/parent ?i]
(get-children ?b ?child)
]
]
:inputs [:query-page]
}
#+END_QUERY