aboutsummaryrefslogtreecommitdiff
path: root/build-site.el
blob: 22ce82b1b9869da5f1271023a9fb7c9149d72ea4 (plain)
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
(package-initialize)
(require 'ox-publish)
(require 'org-publish-rss)

(defun my/file-to-string (file)
  (with-temp-buffer
    (insert-file-contents file)
    (buffer-string)))

(setq org-html-validation-link nil
      org-html-head-include-scripts nil
      org-html-doctype "html5"
      org-html-html5-fancy t
      org-html-head-include-default-style nil
      org-html-head (my/file-to-string "templates/head.html")
      org-html-postamble nil
      org-export-with-section-numbers nil
      org-export-with-timestamps nil
      org-export-with-toc nil)

(defun my/sitemap-format-entry (entry style project)
  (let ((title (org-publish-find-title entry project))
	(date (org-publish-find-date entry project)))
    (format "%s - [[file:%s][%s]]"
	    (format-time-string "%F" date)
	    entry
	    title)))

(defun my/sitemap-function (title list)	; todo change this
  (setq spec
	(list (cons ?a title)
	      (cons ?l (org-list-to-org list))))
  (format-spec (my/file-to-string "templates/blog-sitemap.org") spec))

(setq org-publish-project-alist
      (list
       (list "blog"
	     :recursive t
	     :base-directory "./src/blog"
	     :publishing-directory "./public/blog"
	     :publishing-function 'org-html-publish-to-html
	     :auto-sitemap t
	     :sitemap-title "Lemurblog"
	     :sitemap-filename "index.org"
	     :sitemap-sort-files 'anti-chronologically
	     :sitemap-format-entry 'my/sitemap-format-entry
	     :sitemap-function 'my/sitemap-function
	     :auto-rss t
	     :rss-description "The Lemurian Mage's Awesome Lemur Blog"
	     :rss-link "https://lemurianmage.srht.site/blog"
	     :rss-copyright "nah"
	     :completion-function 'org-publish-rss)
       (list "pages"
             :recursive nil
             :base-directory "./src"
             :publishing-function 'org-html-publish-to-html
             :publishing-directory "./public")
       (list "assets"
	     :recursive t
	     :base-directory "./src/assets"
	     :base-extension 'any
	     :include '("../blog/rss.xml")
	     :publishing-function 'org-publish-attachment
	     :publishing-directory "./public/assets")))

(delete-directory "public" :recursive t)
(setenv "TZ" "UTC0")			; remove the timezone from rss output
(org-publish-all t)
(delete-file "src/blog/rss.xml~")	; I have no clue why this thing appears at all

(message "Build done!")