Is it possible to query a tag in a referenced block?

I have a page X which consists only of block references to multiple other pages A,B,C. The blocks in ABC can be tagged with either “Definition” or “Fact.”

Is it possible for a query to return blocks which are referenced on X and are tagged with “Definition”?

You are probably looking for something like this:

{:query [:find (pull ?b [*])
    [?tag :block/name ?tag-name]
    [(= ?tag-name "definition")]
    [?page :block/name ?page-name]
    [(= ?page-name "x")]
    [?page-block :block/page ?page]
    [?page-block :block/refs ?b]
    [?b :block/refs ?tag]
1 Like

Thanks. This doesn’t seem to work, I’ll try to troubleshoot it later.

Set up to use with the provided query. Hope this helps with troubleshooting. (Last bullet is query posted, showing the result)

1 Like

Thanks so much for checking this. The problem was that I wasn’t using all lowercase in the query when referencing the page name.

1 Like