-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.el
68 lines (58 loc) · 2.32 KB
/
publish.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(message "using emacs version: %s" emacs-version)
(setq package-enable-at-startup nil)
(defconst my/current-dir
(if load-file-name
(file-name-directory load-file-name)
(expand-file-name ".")))
(defconst my/emacs-dir
;;; Customized `user-emacs-directory', used for several separate configurations.
(let ((user-dir (getenv "EMACS_USER_DIRECTORY")))
(if user-dir
user-dir
(expand-file-name ".emacs.d" my/current-dir))))
(defconst my/org-dir
;;; Org files directory
(expand-file-name "org" my/current-dir))
(setq straight-base-dir (expand-file-name "straight" my/emacs-dir))
(unless (file-exists-p straight-base-dir)
(make-directory straight-base-dir t))
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" straight-base-dir))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq org-id-locations-file (expand-file-name ".org-id-locations" my/emacs-dir))
(use-package org-roam
:straight t
:init
(setq org-roam-directory my/org-dir)
(setq org-roam-db-location (expand-file-name "org-roam.db" my/org-dir))
(setq org-roam-v2-ack t)
(org-roam-db-autosync-mode)
(unless (file-exists-p org-id-locations-file)
(let ((org-id-files (org-roam--list-files org-roam-directory))
org-agenda-files)
(org-id-update-id-locations))))
(use-package ox-hugo
:straight (ox-hugo :type git :host github :repo "kaushalmodi/ox-hugo"
:fork (:host github
:repo "jethrokuan/ox-hugo")))
(defun publish (file)
(with-current-buffer (find-file-noselect file)
(setq org-hugo-base-dir my/current-dir)
(org-hugo-export-wim-to-md)))
(defun publish-all ()
(let* ((all-org-files (file-expand-wildcards (expand-file-name "*.org" my/org-dir)))
(enable-dir-local-variables nil))
(org-roam-update-org-id-locations)
(message (format "updating org-id-locations-file for roam: %s" org-id-locations-file))
(dolist (f all-org-files)
(publish f))))