Is there a way to query empty pages?

OK, I spent way too long on this today, but it’s working:

#+BEGIN_QUERY
{:title [ :b "Missing Pages" ]
    :query [:find ?tag (count ?tagcount)
        :keys name count
        :where
        [?p :block/name ?tag]
        [?p :block/journal? false]
        [(missing? $ ?p :block/file)]
        [(missing? $ ?p :block/alias)]
        [?b :block/refs ?p ?tagcount]
    ]

 :result-transform (fn [result] (sort-by (fn [r] (get-in r [:count])) > result))

;:view pprint

 :view (fn [rows] [:table [:thead [:tr [:th "Page"] [:th "Count"] ] ]
    [:tbody (for [r rows] [:tr
       [:td [:a {:href (str "#/page/" (clojure.string/replace (get-in r [:name]) "/" "%2F"))} (get-in r [:name])] ]
       [:td [:a {:href (str "#/page/" (get-in r [:name]))} (get-in r [:count])] ]
    ])]
   ])

}
#+END_QUERY

Also, this is relevant. I wrote a PR to allow different styling for empty pages and aliases, but it’s yet to be reviewed:

1 Like