Skip to content

Instantly share code, notes, and snippets.

@jdiez17
Last active March 6, 2020 13:58
Show Gist options
  • Save jdiez17/2a6d3e13d91db5b3faacb7966ce45845 to your computer and use it in GitHub Desktop.
Save jdiez17/2a6d3e13d91db5b3faacb7966ce45845 to your computer and use it in GitHub Desktop.
(defun jdiez/org-roam--backlinks-list (file)
(--reduce-from
(concat acc (format " - [[file:%s][%s]]\n\t - %s\n"
(file-relative-name (car it) org-roam-directory)
(org-roam--get-title-or-slug (car it))
(plist-get (car (cdr it)) :content)))
"" (org-roam-sql [:select [file-from, properties] :from file-links :where (= file-to $s1)] file)))
(defun jdiez/org-export-preprocessor (backend)
(let ((links (jdiez/org-roam--backlinks-list (buffer-file-name))))
(unless (string= links "")
(save-excursion
(goto-char (point-max))
(insert (concat "\n* Backlinks\n") links)))))
(add-hook 'org-export-before-processing-hook 'jdiez/org-export-preprocessor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment