Last active
March 6, 2020 13:58
-
-
Save jdiez17/2a6d3e13d91db5b3faacb7966ce45845 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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