I have written some code that, in the org-roam buffer, displays backlinks not just to a file, but to any nodes in that file. But given how the org-roam database works—listing, for every node, its associated files—this is limited to calling the org-roam buffer on a file-level node, not any children nodes. Is there a way to generate, for any node, its child nodes? I think this discussion is related: has any progress been made on this in org-roam?
For those who are interested, the code I’ve written to generate the child backlinks is this:
(defun azr/org-roam-get-child-nodes (node) "Get list of child nodes of NODE, if NODE is a file." (unless (= 1 (org-roam-node-point node)) (error "NODE is not a file.")) (let ((file (org-roam-node-file node))) (->> (org-roam-node-list) (-filter (lambda (elt) (equal file (org-roam-node-file elt)))) (-filter (lambda (elt) (/= 1 (org-roam-node-point elt))))))) (defun azr/org-roam-child-backlinks-section (node) "Like org-roam-backlinks-section but for backlinks to children nodes, if NODE is a file." (when-let ((backlinks (seq-sort #'org-roam-backlinks-sort (-flatten-n 1 (mapcar #'org-roam-backlinks-get (azr/org-roam-get-child-nodes node)))))) (magit-insert-section (org-roam-backlinks) (magit-insert-heading "Backlinks (children):") (dolist (backlink backlinks) (org-roam-node-insert-section :source-node (org-roam-backlink-source-node backlink) :point (org-roam-backlink-point backlink) :properties (org-roam-backlink-properties backlink))) (insert ?\n)))) (setq org-roam-mode-section-functions '(org-roam-backlinks-section azr/org-roam-child-backlinks-section org-roam-reflinks-section))
It looks like this: