June 4, 2020
tags Emacs Org-mode Org-roam Export all org-roam files to Hugo markdown (this might take some time)
From: jethrokuan/dots
(defun benmezger/org-roam-export-all () "Re-exports all Org-roam files to Hugo markdown." (interactive) (dolist (f (org-roam--list-all-files)) (with-current-buffer (find-file f) (when (s-contains? "SETUPFILE" (buffer-string)) (org-hugo-export-wim-to-md))))) Adding an empty #+SETUPFILE: forces benmezger/org-roam-export-all to export the file.
May 30, 2020
tags Org-mode Emacs Org-roam Org-roam has roam-protocol, which we can call throughout the system just like Org-mode Firefox bookmarks.
Org-roam protocol supports specifying the roam template to use. Template is the template key for a template in org-roam-capture-ref-templates. More documentation on the templating system can be found here.
These templates should contain a #+ROAM_KEY: ${ref} in it.
Roam-ref protocol # Find and creates from with a specific ROAM_KEY
...
Source: https://github.com/jethrokuan/dots/blob/0064ea2aab667f115a14ce48292731db46302c53/.doom.d/config.el#L488
The following exports all roam files to Hugo and includes backlinks pre-processor.
(defun jethro/org-roam-export-all () "Re-exports all Org-roam files to Hugo markdown." (interactive) (dolist (f (org-roam--list-all-files)) (with-current-buffer (find-file f) (when (s-contains? "SETUPFILE" (buffer-string)) (org-hugo-export-wim-to-md))))) (defun jethro/org-roam--backlinks-list (file) (when (org-roam--org-roam-file-p file) (mapcar #'car (org-roam-db-query [:select :distinct [from] :from links :where (= to $s1) :and from :not :like $s2] file "%private%")))) (defun jethro/org-export-preprocessor (_backend) (when-let ((links (jethro/org-roam--backlinks-list (buffer-file-name)))) (insert "\n** Backlinks\n") (dolist (link links) (insert (format "- [[file:%s][%s]]\n" (file-relative-name link org-roam-directory) (org-roam--get-title-or-slug link)))))) (add-hook 'org-export-before-processing-hook #'jethro/org-export-preprocessor))