summaryrefslogtreecommitdiff
path: root/publish.el
blob: 352c88f87ae20873381f5add9ea78eaa023c483c (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
72
73
74
75
76
77
78
79
80
81
(require 'ox-publish)

(require 'package)
(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)

(defun get-org-file-title(entry style project)
  (setq timestamp (org-timestamp-format (car (org-publish-find-property entry :date project)) "%B %d, %Y"))
  (setq tag-list (org-publish-find-property entry :filetags project))
  (setq tag-list-str (mapconcat 'identity tag-list ","))
  (setq result (format "%s created on %s\n#+begin_sitemap_tag\n%s\n#+end_sitemap_tag\n" (org-publish-sitemap-default-entry entry style project) timestamp tag-list-str))
  )

(defun my-sitemap-function (title list)
  (concat "#+TITLE: " title "\n\n"
          "#+DATE: " (format-time-string "%Y-%m-%d at %H:%M") "\n\n"
          "#+HTML_LINK_HOME: /\n\n"
          "#+HTML_LINK_UP: /\n\n"
	        (org-list-to-org list)))

(setq org-publish-project-alist
      (list
       (list "matthewkosarek.xyz"
             :recursive t
             :base-directory "./_posts"
             :publishing-directory "./posts"
             :publishing-function: 'org-html-publish-to-html
             :with-toc nil
             :with-author nil
             :section-numbers nil
             :time-stamp-file nil
             :with-title nil
             :with-date nil
             :html-preamble-format '(("en" "
  <div class=\"org-article-title\">
    <h1>%t</h1>
    <span>Last modified: %d</span>
  </div>
"))
             :auto-sitemap t
             :sitemap-sort-files "chronologically"
             :sitemap-title "Matthew's Blog Posts"
             :sitemap-format-entry (lambda (entry style project) (get-org-file-title entry style project))
             :sitemap-function (lambda (title list) (my-sitemap-function title list))
             )))


(setq org-html-htmlize-output-type 'css)
(setq org-html-htmlize-font-prefix "org-")

(setq org-html-validation-link nil
      org-html-head-include-scripts nil       ;; Use our own scripts
      org-html-head-include-default-style nil ;; Use our own styles
      org-html-head "
<link rel=\"stylesheet\" href=\"/index.css\" />
<link rel=\"stylesheet\" href=\"/posts/post.css\" />
<link rel=\"shortcut icon\" href=\"/favicon/favicon.ico\" type=\"image/x-icon\">
<script src='/posts/post.js'></script>
"
      org-html-inline-images t
      org-html-link-home "/"
      org-html-link-up "/posts/sitemap.html"
      org-html-html5-fancy t
      org-html-home/up-format "<div id=\"org-div-home-and-up\">
 <a accesskey=\"h\" href=\"%s\"> UP </a>
 <a accesskey=\"H\" href=\"%s\"> HOME </a>
</div>"
      )

(org-publish-all t)

(message "Build Complete")