-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpublish.el
61 lines (49 loc) · 1.79 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
;; The Lisp Spectrum project website
;; To publish the website run the command "emacs -Q -l publish.el"
;; You can then serve the website from the created public folder
(require 'package)
;; Download packages in a local folder
(setq package-user-dir (expand-file-name "./.packages"))
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("elpa" . "https://elpa.gnu.org/packages/")))
;; Initialize the package system
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
;; Install dependencies
(package-install 'htmlize)
(require 'ox-publish)
;; Customize the HTML output
(setq org-html-validation-link nil ;; Don't show validation link
org-html-head-include-default-style nil ;; Use our own styles
org-html-head "<link rel=\"stylesheet\" href=\"https://cdn.simplecss.org/simple.min.css\" />")
(defun rename-project-files (from-regex to)
(dolist (from-file (directory-files-recursively "./public" from-regex))
(let ((to-file-name (replace-regexp-in-string from-regex to
from-file t)))
(message (format "renaming %s to %s" from-file to-file-name))
(rename-file from-file to-file-name t))))
(setq org-publish-project-alist
(list
(list
"lisp-spectrum"
:base-directory "."
:base-extension "org"
:publishing-directory "./public"
:publishing-function 'org-html-publish-to-html
:recursive t
:with-toc nil
:headline-levels 6
:with-author nil
:with-creator nil
:with-date nil
:with-timestamps nil
:time-stamp-file nil
:section-numbers nil
;; function to be called after publishing the project
:completion-function (lambda (_)
(rename-project-files "README" "index")
(message "Project is now published")))))
(defun publish ()
(org-publish-all t))
(publish)