diff options
author | JSDurand <mmemmew@gmail.com> | 2021-08-24 16:43:49 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2021-08-24 16:43:49 +0800 |
commit | 99d3e48af3944fc749694c52989b924fc3f080f4 (patch) | |
tree | ed1ecfeb51b3dc3008925d3cad25e2127d56867e | |
parent | 36f8bee3404cdd0960eb74a29b3f61c525bd55a5 (diff) |
Use Org-mode to publish a blog
* org-conf.el (org-publish-project-alist): The settings are stored in
this variable.
(durand-sitemap-custom-string-alist): My hack to insert some strings
in sitemap files.
(durand-org-publish-sitemap): Custom function to generate sitemaps.
(durand-org-publish-sitemap-format): Add a date to the format of the
entries.
(ox): Add a require to avoid some errors at startup.
-rw-r--r-- | org-conf.el | 110 |
1 files changed, 109 insertions, 1 deletions
diff --git a/org-conf.el b/org-conf.el index 1f1d8cd..019c033 100644 --- a/org-conf.el +++ b/org-conf.el @@ -6,6 +6,10 @@ ;; org-format-latex-options (plist-put org-format-latex-options :scale 1.5) ) +;;; org-export + +(require 'ox) + ;;; org capture bookmark (setq org-capture-bookmark nil) @@ -542,10 +546,69 @@ If DESC is non-`nil', then it is the description of the new link." ;;; publishing settings +;;;;; Projects settings + (setq org-publish-project-alist (list (list - "blog" + "website" + :components (list "code" "life" "main")) + (list + "code" + :base-directory (directory-file-name + (expand-file-name + "code" (expand-file-name + "blog" org-directory))) + :base-extension "org" + :publishing-directory (directory-file-name + (expand-file-name + "public" org-directory)) + :publishing-function #'org-html-publish-to-html + :section-numbers nil + :with-toc nil + :with-email t + :with-creator t + :auto-sitemap t + :recursive t + :sitemap-function #'durand-org-publish-sitemap + :sitemap-format-entry #'durand-org-publish-sitemap-format + :sitemap-date-format "Published: %F %a %R" + :sitemap-filename "code-sitemap.org" + :sitemap-title "About coding" + :html-link-home "index.html" + :sitemap-sort-files 'anti-chronologically + :html-head "<link rel=\"stylesheet\" type=\"text/css\" + href=\"website.css\"/>" + :html-preamble t) + (list + "life" + :base-directory (directory-file-name + (expand-file-name + "life" (expand-file-name + "blog" org-directory))) + :base-extension "org" + :publishing-directory (directory-file-name + (expand-file-name + "public" org-directory)) + :publishing-function #'org-html-publish-to-html + :section-numbers nil + :with-toc nil + :with-email t + :with-creator t + :auto-sitemap t + :recursive t + :sitemap-function #'durand-org-publish-sitemap + :sitemap-format-entry #'durand-org-publish-sitemap-format + :sitemap-date-format "Published: %F %a %R" + :sitemap-filename "life-sitemap.org" + :sitemap-title "My life" + :html-link-home "index.html" + :sitemap-sort-files 'anti-chronologically + :html-head "<link rel=\"stylesheet\" type=\"text/css\" + href=\"website.css\"/>" + :html-preamble t) + (list + "main" :base-directory (directory-file-name (expand-file-name "blog" org-directory)) @@ -556,5 +619,50 @@ If DESC is non-`nil', then it is the description of the new link." :publishing-function #'org-html-publish-to-html :section-numbers nil :with-toc nil + :with-email t + :with-creator t + :auto-sitemap nil + :recursive nil + :html-head "<link rel=\"stylesheet\" type=\"text/css\" + href=\"website.css\"/>" :html-preamble t))) +;;;;; Sitemap function + +;;;;;; A hack to insert some string in the sitemap file. + +(defvar durand-sitemap-custom-string-alist + (list + (cons "About coding" + "This is the coding blog. It contains my coding experiments, or \ +one might think of them as development diaries.") + (cons "My life" + "This is my casual blog. It contains articles about my plain \ +life.")) + "An association list that relates the title of the sitemap and the string to insert.") + +;;;;;; Custom sitemap function + +(defun durand-org-publish-sitemap (title rep) + "Return the sitemap as a string. +TITLE is the title of the sitemap. + +REP is a representation of the files and directories in the +project. Use such functions as `org-list-to-org' or +`org-list-to-subtree' to transform it." + (format "#+TITLE: %s\n#+AUTHOR: JSDurand\n%s#+DATE: <%s>\n\n%s\n\n%s" + title + "#+HTML_LINK_UP: index.html" + (format-time-string "%F %a %R") + (cdr (assoc title durand-sitemap-custom-string-alist #'string=)) + (org-list-to-org rep))) + +;;;;;; Custom sitemap format + +(defun durand-org-publish-sitemap-format (entry _style project) + "Format the entry for the sitemap. +A date is added." + (format "[[file:%s][(%s) %s]]" + entry (format-time-string + "%F %R" (org-publish-find-date entry project)) + (org-publish-find-title entry project))) |