Skip to content

Instantly share code, notes, and snippets.

@tombarys
Last active October 5, 2023 01:18
Show Gist options
  • Save tombarys/f1d5896cddfc655fa72b822de6ecbcbc to your computer and use it in GitHub Desktop.
Save tombarys/f1d5896cddfc655fa72b822de6ecbcbc to your computer and use it in GitHub Desktop.
Show children block count
;; Instructions for including the Clojure script (this) into your Roam can be found in my article
;; here: https://lifehacky.net/how-to-list-namespaces-and-find-more-in-roam-research-5c25d9f24556
;; Search for section "How to make it work in your Roam?" and think of "better-search" as of "children-block-count"
(ns reddit.8-7-2022-reagent
(:require [roam.datascript :as rd]
[reagent.core :as r]
[roam.datascript.reactive :as rdr]))
(defn show-num [uid]
(r/with-let [*kids (rdr/q '[:find (count ?b) .
:in $ ?uid
:where
[?a :block/uid ?uid]
[?b :block/parents ?a]] uid)]
[:span @*kids]))
(defn main [{:keys [block-uid]}]
(show-num block-uid))
@Christian-Klaperek
Copy link

Christian-Klaperek commented Oct 5, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment