summaryrefslogtreecommitdiffstats
path: root/build.el
blob: 4fb9d06bd20154b0c2ff5f4dcc8be174e98a4789 (plain) (blame)
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
72
73
74
75
76
77
78
79
80
81
(require 'ox-publish)
(require 'ox-html)

;; general settings
(setq org-html-extension "xhtml")

;; custom URIs
(org-link-set-parameters "xmpp")
(org-link-set-parameters "monero")

;; html output customization
(setq org-html-validation-link nil
      org-html-head-include-scripts nil
      org-html-head-include-default-style nil
      org-html-head "<link rel=\"stylesheet\" type=\"text/css\"
href=\"./assets/styles.css\"/>")

;; exclude sections for certain backends
(defun wk/exclude-backends (backend)
  (setq org-export-exclude-tags
        `(,(concat "noexport_" (symbol-name backend)) "noexport")))
(add-hook 'org-export-before-parsing-functions #'wk/exclude-backends)

;; customize the html exporter
(defun wk/org-html--tags (tags info)
  "Format TAGS into HTML.
INFO is a plist containing export options."
  (when tags
    (format "<span class=\"tag\">%s</span>"
	    (mapconcat
	     (lambda (tag)
               (if (string-prefix-p "noexport" tag)
                   ""
	         (format "<span class=\"%s\">%s</span>"
		         (concat (plist-get info :html-tag-class-prefix)
			         (org-html-fix-class-name tag))
		         tag)))
	     tags "&#xa0;"))))

(defun wk/org-html-format-headline-function
    (todo _todo-type priority text tags info)
  "Default format function for a headline.
See `org-html-format-headline-function' for details and the
description of TODO, PRIORITY, TEXT, TAGS, and INFO arguments."
  (let ((todo (org-html--todo todo info))
	(priority (org-html--priority priority info))
	(tags (wk/org-html--tags tags info)))
    (concat todo (and todo " ")
	    priority (and priority " ")
	    text
	    (and tags "&#xa0;&#xa0;&#xa0;") tags)))

(setq org-html-format-headline-function #'wk/org-html-format-headline-function)

;; project definition
(setq org-publish-project-alist
      '(("http-content"
         :base-directory "./content/"
         :base-extension "org"
         :publishing-directory "./public/http"
         :recursive t
         :publishing-function org-html-publish-to-html

         :headline-levels 3
         :with-author nil
         :with-creator nil
         :with-toc nil
         :section-numbers nil
         :time-stamp-file nil)
        ("http-assets"
         :base-directory "./content/assets"
         :base-extension any
         :exclude "\\.\\*.org"
         :publishing-directory "./public/http/assets"
         :recursive t
         :publishing-function org-publish-attachment)))
         

;; export all 
(org-publish-all t)
(message "Build complete")