1 ;;; my-publish.el --- Publish blog with org-mode -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2017 Peng Li
5 ;; Author: Peng Li <seudut@gmail.com>
6 ;; Keywords: lisp, abbrev
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
23 ;; Using this emacs script to publish the blog org file
27 ;; (defconst root-dir "~/Private/blog/")
32 ;; To prevent inline-css when exporting html. will use external css
33 (setq org-html-htmlize-output-type 'css)
37 ;; "<link rel='stylesheet' href='" css-file "' />\n"
38 "<link rel='stylesheet' href='../css/main.css' />\n"
39 "<link rel='stylesheet' href='../css/code.css' />"
44 " <header id= 'banner' > "
45 "<h1><a href= '/' >Peng Li</a></h1>"
48 "<li><a href= './' >About</a></li>"
49 "<li><a href= './sitemap.html' >Blog</a></li>"
50 "<li><a href= './home.html' >Home</a></li>"
56 <p><span style=\"float: left;\"><a href= \"/blog.xml\">RSS</a></span>
57 License: <a href= \"https://creativecommons.org/licenses/by-sa/4.0/\">CC BY-SA 4.0</a></p\n")
59 (defun blog-setup-project-alist (root-dir &optional output-dir)
60 "Set project alist. `output-dir' is the directory of publish-directory.
61 `root-dir' is the root directory of blog repository."
62 (unless (> (length output-dir) 0)
63 (setq output-dir (concat root-dir "/_site/")))
64 (message "Blog dir is: %s\nOut dir is: %s"
67 (setq org-publish-project-alist
70 :base-directory ,root-dir
72 :publishing-directory ,output-dir
74 :publishing-function org-html-publish-to-html
78 ;; disable home/up div
79 :html-home/up-format ""
84 :html-head-include-default-style nil
85 :html-head-include-scripts nil
86 :html-head-extra ,blog-extra-head
87 :html-preamble ,blog-header
88 :html-postamble ,blog-footer)
91 :base-directory ,(concat root-dir "/posts")
93 :publishing-directory ,(concat output-dir "/posts")
95 :publishing-function org-html-publish-to-html
100 :html-home/up-format ""
103 ;; Add css file, preamble and posamble
105 :html-head-include-default-style nil
106 :html-head-include-scripts nil
107 :html-head-extra ,blog-extra-head
108 :html-preamble ,blog-header
109 :html-postamble ,blog-footer
113 :sitemap-filename "sitemap.org"
114 :sitemap-title "Sitemap")
117 :base-directory ,(concat root-dir "/css")
119 :publishing-directory ,(concat output-dir "/css")
120 :publishing-function org-publish-attachment
123 :base-directory ,(concat root-dir "/cgi-bin")
125 :publishing-directory ,(concat output-dir "/cgi-bin")
126 :publishing-function org-publish-attachment
128 ("blog" :components ("blog-pages" "blog-posts" "blog-css" "blog-cgi")))))
130 (provide 'my-publish)
131 ;;; publish.el ends here