mirror.dongdigua.github.io/org/publish_config.el

104 lines
3.1 KiB
EmacsLisp
Raw Permalink Normal View History

2022-12-10 14:05:00 +08:00
(require 'package)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(dolist (p '(webfeeder htmlize))
2022-12-10 14:05:00 +08:00
(when (not (package-installed-p p))
(package-install p)))
2022-12-10 14:05:00 +08:00
(eval-when-compile
(require 'org)
2023-05-29 16:10:46 +08:00
(require 'ox-publish)
(require 'ox-html)
(require 'htmlize)
(require 'webfeeder))
(setq org-html-validation-link nil
;; https://emacs-china.org/t/org-emacs-script-org-publish-all/20782
org-html-htmlize-output-type 'css
2024-11-24 20:33:42 +08:00
org-html-head-include-default-style nil
2023-01-09 18:07:16 +08:00
org-export-with-toc 1
org-export-with-sub-superscripts '{})
2023-05-29 16:10:46 +08:00
(setq org-html-postamble-format
'(("en"
"
<p>dongdigua CC BY-NC-SA 禁止转载到私域(公众号非自己托管的博客等)</p>
<p>Email me to add comment</p>
<p>Proudly made with Emacs Org mode</p>
<p class=\"date\">Date: %d Build: %T Size: PAGE_SIZE</p>
")))
2023-06-06 16:07:17 +08:00
(setq org-html-home/up-format "
<div id=\"org-div-home-and-up\">
<a accesskey=\"h\" href=\"%s\"> index </a>
2023-06-06 16:07:17 +08:00
|
<a accesskey=\"H\" href=\"%s\"> ~dongdigua </a>
</div>")
2022-07-13 16:26:16 +08:00
(setq org-publish-project-alist
'(("org-pages"
:base-directory "."
:base-extension "org"
2022-09-11 11:20:31 +08:00
:publishing-directory "./../"
2022-07-13 16:26:16 +08:00
:recursive t
:publishing-function org-html-publish-to-html
:preserve-breaks t
2022-09-15 11:33:55 +08:00
2024-11-18 17:51:32 +08:00
:html-head "<link rel='stylesheet' href='css/main.css' /><link rel='stylesheet' href='css/org.small.css' /><link rel='stylesheet' href='css/dark.css' />"
;; :html-head-include-default-style nil
:html-link-home "https://dongdigua.github.io"
:html-link-up "./../posts"
:html-postamble t
2022-07-13 16:26:16 +08:00
)))
2022-09-25 12:53:07 +08:00
;; from .emacs
(defun my/orgurl (proto)
(defvar proto proto) ;; important
(org-link-set-parameters proto
:export
(lambda (link description format _)
(let ((url (format "%s:%s" proto link)))
(format "<a href=\"%s\">%s</a>" url (or description url))))))
(my/orgurl "gopher")
(my/orgurl "gemini")
;; https://emacs.stackexchange.com/questions/36366/disable-auto-id-generation-in-org-mode-html-export
;; BUG: will cause toc not working, but I don't use much, so just add id manually
(defun html-body-id-filter (output backend info)
"Remove random ID attributes generated by Org."
(when (eq backend 'html)
(replace-regexp-in-string
" href=\"#org[[:alnum:]]\\{7\\}\""
""
(replace-regexp-in-string
" id=\"[[:alpha:]-]*org[[:alnum:]]\\{7\\}\""
""
output t)
t)))
(add-to-list 'org-export-filter-final-output-functions 'html-body-id-filter)
2024-01-28 15:09:07 +08:00
(defun my/delete-multiple (src l)
(mapcar (lambda (x) (setq src (delete x src))) l)
src)
2022-07-13 16:26:16 +08:00
(defun myweb-publish ()
"Publish myweb."
(interactive)
(setq debug-on-error t)
(org-publish-all)
(webfeeder-build
"feed.xml"
2022-09-11 11:20:31 +08:00
"./../"
"https://dongdigua.github.io"
2024-01-28 15:09:07 +08:00
(my/delete-multiple (directory-files "./../" nil ".*\.html$") '("about.html" "my_timeline.html" "kernel.html" "404.html" "xmr.html" "index.html"))
:title "dongdigua's blog"
:description "Blog!"
:builder 'webfeeder-make-rss)
2023-05-29 16:10:46 +08:00
(kill-emacs))
2022-07-13 16:26:16 +08:00