The contextual sidebar: query current page and organize pages in indexes

Hello! I saw your idea in another thread about structuring notes, and took some time to implement it to my own logseq. My problem with using simple queries was that there was some friction for me to see the whole index block, so I used advanced queries. Disclaimer though, I only knew a bit of python programming, and read only the first two chapters of a book on lisp, so I probably don’t know what I’m doing. Here’s the code! Hope it helps!


#+BEGIN_QUERY
{
:title [:b "index"]
:query [
            :find (pull ?iblock [*])
            :in $ ?pname %
            :where
            [?current-page :page/name ?pname]
            [?itag :page/name ".index"]
            [?iblock :block/refs ?itag]
            (get-children ?iblock ?pblock)
            [?pblock :block/refs ?current-page]
            ]
:inputs [:current-page
            [
                [(get-children ?parent ?child) [?child :block/parent ?parent]]
                [(get-children ?parent ?child) [?t :block/parent ?parent] 
                      (get-children ?t ?child)]
            ]
]
:breadcrumb-show? false
:table-view? false
:group-by-page? false
} 
#+END_QUERY

Edit: I use #.index instead of #index

4 Likes