Can LogSeq glossaries and abbreviation directories

If you provide your data with properties like this:

…then you can get results like these:



…by using queries like these:

#+BEGIN_QUERY
{:title [:h2 "All data"]
 :query [:find ?abbr ?name ?descr ?eng ?fr ?area
  :keys abbr name descr eng fr area
   :where
     [?b :block/properties ?p]
     [(get ?p :abbr) ?abbr]
     [(get ?p :name) ?name]
     (or
       [(get ?p :eng) ?eng]
       (and
         (not [(get ?p :eng) ?eng])
         [(str "-") ?eng]
       )
     )
     (or
       [(get ?p :fr) ?fr]
       (and
         (not [(get ?p :fr) ?fr])
         [(str "-") ?fr]
       )
     )
     [(get ?p :descr) ?descr]
     [(get ?p :area) ?area]
 ]
 :result-transform (fn [result] (sort-by (fn [res] (get res :abbr)) result))
 :view (fn [result]
   [:div.table-wrapper
     [:table.table-auto
       [:thead
         [:tr
           [:th {:width "12%"} [:strong [:font {:size "4"} "Abbr"]]]
           [:th {:width "12%"} [:strong [:font {:size "4"} "Name"]]]
           [:th [:strong [:font {:size "4"} "Description"]]]
           [:th {:width "12%"} [:strong [:font {:size "4"} "English"]]]
           [:th {:width "12%"} [:strong [:font {:size "4"} "French"]]]
           [:th {:width "20%"} [:strong [:font {:size "4"} "Area"]]]
         ]
       ]
       [:tbody
         (for [res result]
           [:tr
             [:td (get res :abbr)]
             [:td (get res :name)]
             [:td (get res :descr)]
             [:td (get res :eng)]
             [:td (get res :fr)]
             [:td (get res :area)]
           ]
         )
       ]
     ]
   ]
 )
}
#+END_QUERY

#+BEGIN_QUERY
{:title [:h2 "Abbreviations Drinking water"]
 :query [:find ?abbr ?name
   :keys abbr name
   :where
     [?b :block/properties ?p]
     [(get ?p :abbr) ?abbr]
     [(get ?p :name) ?name]
     [(get ?p :area) ?area]
     [(clojure.string/includes? ?area "drinking water")]
 ]
 :result-transform (fn [result] (sort-by (fn [res] (get res :abbr)) result))
 :view (fn [result]
   [:div.table-wrapper
     [:table.table-auto
       [:thead
         [:tr
           [:th [:strong [:font {:size "4"} "Abbr."]]]
           [:th [:strong [:font {:size "4"} "Designation"]]]
         ]
       ]
       [:tbody
         (for [res result]
           [:tr
             [:td (get res :abbr)]
             [:td (get res :name)]
           ]
         )
       ]
     ]
   ]
 )
}
#+END_QUERY

#+BEGIN_QUERY
{:title [:h2 "Abbreviations Waste water"]
 :query [:find ?abbr ?name
   :keys abbr name
   :where
     [?b :block/properties ?p]
     [(get ?p :abbr) ?abbr]
     [(get ?p :name) ?name]
     [(get ?p :area) ?area]
     [(clojure.string/includes? ?area "waste water")]
 ]
 :result-transform (fn [result] (sort-by (fn [res] (get res :abbr)) result))
 :view (fn [result]
   [:div.table-wrapper
     [:table.table-auto
       [:thead
         [:tr
           [:th [:strong [:font {:size "4"} "Abbr."]]]
           [:th [:strong [:font {:size "4"} "Designation"]]]
         ]
       ]
       [:tbody
         (for [res result]
           [:tr
             [:td (get res :abbr)]
             [:td (get res :name)]
           ]
         )
       ]
     ]
   ]
 )
}
#+END_QUERY

#+BEGIN_QUERY
{:title [:h2 "Abbreviations sewage treatment plants"]
 :query [:find ?abbr ?name
   :keys abbr name
   :where
     [?b :block/properties ?p]
     [(get ?p :abbr) ?abbr]
     [(get ?p :name) ?name]
     [(get ?p :area) ?area]
     [(clojure.string/includes? ?area "sewage treatment plants")]
 ]
 :result-transform (fn [result] (sort-by (fn [res] (get res :abbr)) result))
 :view (fn [result]
   [:div.table-wrapper
     [:table.table-auto
       [:thead
         [:tr
           [:th [:strong [:font {:size "4"} "Abbr."]]]
           [:th [:strong [:font {:size "4"} "Designation"]]]
         ]
       ]
       [:tbody
         (for [res result]
           [:tr
             [:td (get res :abbr)]
             [:td (get res :name)]
           ]
         )
       ]
     ]
   ]
 )
}
#+END_QUERY

#+BEGIN_QUERY
{:title [:h2 "Glossary Drinking water"]
 :query [:find ?abbr ?name ?descr ?eng ?fr
   :keys abbr name descr eng fr
   :where
     [?b :block/properties ?p]
     [(get ?p :abbr) ?abbr]
     [(get ?p :name) ?name]
     (or
       [(get ?p :eng) ?eng]
       (and
         (not [(get ?p :eng) ?eng])
         [(str "-") ?eng]
       )
     )
     (or
       [(get ?p :fr) ?fr]
       (and
         (not [(get ?p :fr) ?fr])
         [(str "-") ?fr]
       )
     )
     [(get ?p :descr) ?descr]
     [(get ?p :area) ?area]
     [(clojure.string/includes? ?area "drinking water")]
 ]
 :result-transform (fn [result] (sort-by (fn [res] (get res :abbr)) result))
 :view (fn [result]
   [:div.table-wrapper
     [:table.table-auto
       [:thead
         [:tr
           [:th [:strong {:width "12%"} [:font {:size "4"} "Abbr."]]]
           [:th [:strong {:width "12%"} [:font {:size "4"} "Designation"]]]
           [:th [:strong [:font {:size "4"} "Description"]]]
           [:th [:strong {:width "12%"} [:font {:size "4"} "English"]]]
           [:th [:strong {:width "12%"} [:font {:size "4"} "French"]]]
         ]
       ]
       [:tbody
         (for [res result]
           [:tr
             [:td (get res :abbr)]
             [:td (get res :name)]
             [:td (get res :descr)]
             [:td (get res :eng)]
             [:td (get res :fr)]
           ]
         )
       ]
     ]
   ]
 )
}
#+END_QUERY

#+BEGIN_QUERY
{:title [:h2 "Glossary Waste water"]
 :query [:find ?abbr ?name ?descr ?eng ?fr
   :keys abbr name descr eng fr
   :where
     [?b :block/properties ?p]
     [(get ?p :abbr) ?abbr]
     [(get ?p :name) ?name]
     (or
       [(get ?p :eng) ?eng]
       (and
         (not [(get ?p :eng) ?eng])
         [(str "-") ?eng]
       )
     )
     (or
       [(get ?p :fr) ?fr]
       (and
         (not [(get ?p :fr) ?fr])
         [(str "-") ?fr]
       )
     )
     [(get ?p :descr) ?descr]
     [(get ?p :area) ?area]
     [(clojure.string/includes? ?area "waste water")]
 ]
 :result-transform (fn [result] (sort-by (fn [res] (get res :abbr)) result))
 :view (fn [result]
   [:div.table-wrapper
     [:table.table-auto
       [:thead
         [:tr
           [:th [:strong {:width "12%"} [:font {:size "4"} "Abbr."]]]
           [:th [:strong {:width "12%"} [:font {:size "4"} "Designation"]]]
           [:th [:strong [:font {:size "4"} "Description"]]]
           [:th [:strong {:width "12%"} [:font {:size "4"} "English"]]]
           [:th [:strong {:width "12%"} [:font {:size "4"} "French"]]]
         ]
       ]
       [:tbody
         (for [res result]
           [:tr
             [:td (get res :abbr)]
             [:td (get res :name)]
             [:td (get res :descr)]
             [:td (get res :eng)]
             [:td (get res :fr)]
           ]
         )
       ]
     ]
   ]
 )
}
#+END_QUERY

#+BEGIN_QUERY
{:title [:h2 "Glossary Wastewater treatment plants"]
 :query [:find ?abbr ?name ?descr ?eng ?fr
   :keys abbr name descr eng fr
   :where
     [?b :block/properties ?p]
     [(get ?p :abbr) ?abbr]
     [(get ?p :name) ?name]
     (or
       [(get ?p :eng) ?eng]
       (and
         (not [(get ?p :eng) ?eng])
         [(str "-") ?eng]
       )
     )
     (or
       [(get ?p :fr) ?fr]
       (and
         (not [(get ?p :fr) ?fr])
         [(str "-") ?fr]
       )
     )
     [(get ?p :descr) ?descr]
     [(get ?p :area) ?area]
     [(clojure.string/includes? ?area "sewage treatment plants")]
 ]
 :result-transform (fn [result] (sort-by (fn [res] (get res :abbr)) result))
 :view (fn [result]
   [:div.table-wrapper
     [:table.table-auto
       [:thead
         [:tr
           [:th [:strong {:width "12%"} [:font {:size "4"} "Abbr."]]]
           [:th [:strong {:width "12%"} [:font {:size "4"} "Designation"]]]
           [:th [:strong [:font {:size "4"} "Description"]]]
           [:th [:strong {:width "12%"} [:font {:size "4"} "English"]]]
           [:th [:strong {:width "12%"} [:font {:size "4"} "French"]]]
         ]
       ]
       [:tbody
         (for [res result]
           [:tr
             [:td (get res :abbr)]
             [:td (get res :name)]
             [:td (get res :descr)]
             [:td (get res :eng)]
             [:td (get res :fr)]
           ]
         )
       ]
     ]
   ]
 )
}
#+END_QUERY