summaryrefslogtreecommitdiff
path: root/lisp/org-publish-project-alist.el
blob: b4df45f6535373252de6673720a844d9741fa424 (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

(defun file-extension (filename)
  "returns the file extension of the supplied filename,
or nil if no extension was present"
  (car
   (last
    (split-string filename "\\."))))

(defun org-html-publish-or-copy (plist filename pub-dir)
  "If the file extension is `.org`, publish using
org-html-publish-to-html, otherwise use org-pubish-attachment."
  (if (string-equal (file-extension filename) "org")
      (org-html-publish-to-html plist filename pub-dir)
    (org-publish-attachment plist filename pub-dir)))

(let ((root "~/Documents/orgsite/") (generated "generated/"))
  (setq org-publish-project-alist
        (nconc
         (seq-map (lambda (lang)
                    `(,(car lang)
                      :base-directory ,(concat root (car lang))
                      :publishing-directory ,(concat root generated (car lang))
                      :base-extension any
                      :exclude ".*~"
                      :recursive t
                      :publishing-function org-html-publish-or-copy
                      :html-head-extra "<link rel=\"stylesheet\"type=\"text/css\" href=\"../../static/global.css\">"
                      :html-postamble nil
                      :html-preamble ,(concat "<header>
<a id=\"skiptocontent\" href=\"#content\">" (cdr lang) "</a>
<a href=\"/fi/\">FI</a> · <a href=\"/en/\">EN</a>
</header>")
                      :with-toc nil
                      :section-numbers nil
                      :author "Joel Kronqvist"
                      :language ,lang))
                  '(("fi" . "Siirry pääsisältöön") ("en" . "Skip to content")))
         (seq-map (lambda (ident)
                    `(,ident
                      :base-directory ,(concat root ident)
                      :publishing-directory ,(concat root generated ident)
                      :base-extension any
                      :publishing-function org-publish-attachment))
                  '("static" "img")))))