From c380a48df98c07563582abe81826ed97fa3f97af Mon Sep 17 00:00:00 2001 From: Thomas Dehaeze Date: Thu, 16 Apr 2020 19:09:03 +0200 Subject: [PATCH] Add backlinks when exporting to html --- dotfiles/doom.org | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dotfiles/doom.org b/dotfiles/doom.org index 9a48b10..05257db 100644 --- a/dotfiles/doom.org +++ b/dotfiles/doom.org @@ -2107,6 +2107,26 @@ Nice Functions: ) #+end_src +#+begin_src emacs-lisp + (defun my/org-roam--backlinks-list (file) + (if (org-roam--org-roam-file-p file) + (--reduce-from + (concat acc (format "- [[file:%s][%s]]\n" + (file-relative-name (car it) org-roam-directory) + (org-roam--get-title-or-slug (car it)))) + "" (org-roam-db-query [:select [from] :from links :where (= to $s1)] file)) + "")) + + (defun my/org-export-preprocessor (backend) + (let ((links (my/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 'my/org-export-preprocessor) +#+end_src + ** Helm-Bibtex ([[https://github.com/tmalsburg/helm-bibtex][link]]) #+begin_src emacs-lisp (use-package! helm-bibtex