org publish trying to async

This commit is contained in:
Chris Cochrun 2026-03-20 17:10:15 -05:00
parent fb9b9959aa
commit 58bdb5832e

View file

@ -0,0 +1,112 @@
(require 'ox-publish)
(require 'denote)
(require 'denote-org)
(require 'async)
(defun chris/org-publish-site ()
"Publish my website by pushing files to specific locations"
(interactive)
(let* ((notes (directory-files "~/docs/notes" t ".*.org"))
(lessons (directory-files "~/docs/notes/lessons" t ".*.org"))
(denote-directory "~/docs/site/content")
(current-notes (directory-files "~/docs/site/content/notes" t ".*.org"))
(current-lessons (directory-files "~/docs/site/content/teaching" t ".*.org")))
(message "Starting site build")
(cl-loop for file in current-notes
do (delete-file file t))
(message "Removed all notes")
(cl-loop for file in current-lessons
do (delete-file file t))
(message "Removed all lessons")
(cl-loop for file in notes
do (let ((filename (f-filename file)))
(if (not
(string-match-p "\\(_draft\\|_lesson\\|_sermon\\)" filename))
(copy-file
file (concat "~/docs/site/content/notes/" filename) t))))
(message "Copied all notes")
(cl-loop for file in lessons
do (let ((filename (f-filename file)))
(if (not
(string-match-p "\\(_draft\\)" filename))
(copy-file
file (concat "~/docs/site/content/teaching/" filename) t))))
(message "Copied all lessons")
(async-start
(lambda ()
(require 'org)
(require 'denote)
(require 'denote-org)
(find-file "~/docs/site/content/index.org")
(with-current-buffer (current-buffer)
(org-update-all-dblocks)
(save-buffer))
(org-publish "cochrun.xyz"))
(lambda (result)
;; (message result)
(message "Finished publishing site")))))
(defun chris/website-dynamic-block ()
"A function to load up the links on the homepage for the website"
(let (files (directory-files "~/docs/site/content/notes/" t ".*.org"))
(cl-loop for file in files
do (insert (denote--link-get-description file)))))
(defun org-dblock-write:chris-site-notes ()
"A function to load up the links on the homepage for the website"
(let (files (directory-files "~/docs/site/content/notes/" t ".*.org"))
(cl-loop for file in files
do (insert (denote--link-get-description file)))))
(add-to-list 'org-dynamic-block-alist '("chris-site-notes" . chris/website-dynamic-block))
(setq org-publish-project-alist
`(("home"
:base-directory "~/docs/site/content"
:base-extension "org"
:recursive nil
:html-doctype "html5"
:html-html5-fancy t
:html-self-link-headlines t
:html-head "<link rel=\"stylesheet\" href=\"pico.cyan.css\" type=\"text/css\"/>"
:html-head "<link rel=\"stylesheet\" href=\"my.css\" type=\"text/css\"/>"
:publishing-directory "~/docs/notes/site/public/"
:publishing-function org-html-publish-to-html)
("posts"
:base-directory "~/docs/site/content/notes"
:base-extension "org"
:recursive nil
:html-doctype "html5"
:html-html5-fancy t
:html-self-link-headlines t
:htmlized-source t
:html-head "<link rel=\"stylesheet\" href=\"../pico.cyan.css\" type=\"text/css\"/>"
:publishing-directory "~/docs/site/public/notes/"
:publishing-function org-html-publish-to-html)
("teaching"
:base-directory "~/docs/site/content/teaching"
:base-extension "org"
:recursive nil
:html-doctype "html5"
:html-html5-fancy t
:html-self-link-headlines t
:htmlized-source t
:html-head "<link rel=\"stylesheet\" href=\"../pico.cyan.css\" type=\"text/css\"/>"
:publishing-directory "~/docs/site/public/teaching/"
:publishing-function org-html-publish-to-html)
("static"
:base-directory "~/docs/site/assets/"
:base-extension "css\\|txt\\|jpg\\|gif\\|png"
:recursive t
:html-doctype "html5"
:html-html5-fancy t
:publishing-directory "~/docs/site/public/static/"
:publishing-function org-publish-attachment)
("cochrun.xyz" :components ("home" "posts" "static" "teaching"))))
(setq org-html-postamble t
org-html-postamble-format '(("en"
"<footer> <p>Author: %a (%e)</p></footer>")))