77 lines
3.2 KiB
EmacsLisp
77 lines
3.2 KiB
EmacsLisp
;; ox-hugo for exocortex notes
|
|
|
|
;; Set the package installation directory so that packages aren't stored in the
|
|
;; ~/.emacs.d/elpa path.
|
|
(require 'package)
|
|
(setq package-user-dir (expand-file-name "./.packages"))
|
|
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
|
|
("melpa-stable" . "https://stable.melpa.org/packages/")
|
|
("elpa" . "https://elpa.gnu.org/packages/")))
|
|
|
|
;; Initialize the package system
|
|
(package-initialize)
|
|
(unless package-archive-contents
|
|
(package-refresh-contents))
|
|
|
|
;; Install use-package
|
|
(unless (package-installed-p 'use-package)
|
|
(package-install 'use-package))
|
|
(require 'use-package)
|
|
|
|
|
|
(use-package ox-hugo
|
|
:ensure t ;Auto-install the package from Melpa
|
|
:pin melpa ;`package-archives' should already have ("melpa" . "https://melpa.org/packages/")
|
|
:after ox
|
|
:config
|
|
(setq org-hugo-base-dir "~/projects/cosmicflow.space/public/exocortex-hugo-md" )
|
|
(setq org-hugo-default-section-directory "./")
|
|
)
|
|
(setq org-roam-directory "~/projects/thought_garden/")
|
|
|
|
;; See https://ox-hugo.scripter.co/doc/org-cite-citations/
|
|
(with-eval-after-load 'ox-hugo
|
|
(plist-put org-hugo-citations-plist :bibliography-section-heading "Bibliography"))
|
|
|
|
;; modified this function from https://github.com/kaushalmodi/ox-hugo/discussions/585#discussioncomment-2335203
|
|
(defun ox-hugo/export-all (&optional org-files-root-dir dont-recurse)
|
|
"Export all Org files (including nested) under ORG-FILES-ROOT-DIR.
|
|
|
|
All valid post subtrees in all Org files are exported using
|
|
`org-hugo-export-wim-to-md'.
|
|
|
|
If optional arg ORG-FILES-ROOT-DIR is nil, all Org files in
|
|
current buffer's directory are exported.
|
|
|
|
If optional arg DONT-RECURSE is nil, all Org files in
|
|
ORG-FILES-ROOT-DIR in all subdirectories are exported. Else, only
|
|
the Org files directly present in the current directory are
|
|
exported. If this function is called interactively with
|
|
\\[universal-argument] prefix, DONT-RECURSE is set to non-nil.
|
|
|
|
Example usage in Emacs Lisp: (ox-hugo/export-all \"~/org\")."
|
|
(interactive)
|
|
(let* ((org-files-root-dir (or org-files-root-dir default-directory))
|
|
(dont-recurse (or dont-recurse (and current-prefix-arg t)))
|
|
(search-path (file-name-as-directory (expand-file-name org-files-root-dir)))
|
|
(org-files (if dont-recurse
|
|
(directory-files search-path :full "\.org$")
|
|
(directory-files-recursively search-path "\.org$")))
|
|
(num-files (length org-files))
|
|
(cnt 1))
|
|
(if (= 0 num-files)
|
|
(message (format "No Org files found in %s" search-path))
|
|
(progn
|
|
(message (format (if dont-recurse
|
|
"[ox-hugo/export-all] Exporting %d files from %S .."
|
|
"[ox-hugo/export-all] Exporting %d files recursively from %S ..")
|
|
num-files search-path))
|
|
(dolist (org-file org-files)
|
|
(with-current-buffer (find-file-noselect org-file)
|
|
(message (format "[ox-hugo/export-all file %d/%d] Exporting %s" cnt num-files org-file))
|
|
(org-hugo-export-wim-to-md :all-subtrees)
|
|
(setq cnt (1+ cnt))))
|
|
(message "Done!")))))
|
|
(ox-hugo/export-all org-roam-directory)
|
|
|
|
(message "exocortex markdown created")
|