This repository has been archived by the owner on Jul 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
71 lines (58 loc) · 2.31 KB
/
init.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
69
70
71
;;; build.el --- Minimal emacs installation to build the website -*- lexical-binding: t -*-
;; Authors: Bruno Henriques <4727729+bphenriques@users.noreply.github.com>
;;; Commentary:
;;; - Requires KNOWLEDGE_BASE_DIR environment variable
;;
;; Notes:
;; * This is not a package.
;;; Code:
(require 'subr-x)
(toggle-debug-on-error) ;; Show debug informaton as soon as error occurs.
(setq
make-backup-files nil ;; Disable "<file>~" backups.
)
(defconst knowledge-base-dir
(let* ((env-key "KNOWLEDGE_BASE_DIR")
(env-value (getenv env-key)))
(if (and env-value (file-directory-p env-value))
env-value
(error (format "%s is not set or is not an existing directory (%s)" env-key env-value)))))
;;;
;;; Setup packages using straight.el: https://github.com/raxod502/straight.el
;;;
;;; Leads to better reproducible builds as the versions are pinned.
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(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))
(setq straight-use-package-by-default t)
(straight-use-package 'use-package)
;;;
;;; Setup packages
;;;
(use-package ox-hugo
:straight (:type git :host github :repo "kaushalmodi/ox-hugo"))
(setf org-hugo-base-dir knowledge-base-dir)
(setf org-id-extra-files (directory-files-recursively knowledge-base-dir "org"))
;;;
;;; Public functions
;;;
(defun build/export-all ()
"Export all org-files (including nested) under knowledge-base-org-files."
(let ((search-path (concat (file-name-as-directory knowledge-base-dir) "org/")))
(message (format "[build] Looking for files at %s" search-path))
(dolist (org-file (directory-files-recursively search-path "\.org$"))
(with-current-buffer (find-file org-file)
(message (format "[build] Exporting %s" org-file))
(org-hugo-export-wim-to-md :all-subtrees nil nil nil)))
(message "Done!")))
(provide 'build/export-all)
;;; init.el ends here