recent comments
All checks were successful
Build Org Website / build (push) Successful in 50s

This commit is contained in:
2026-05-10 22:32:41 +01:00
parent 8f8a5dddf9
commit b9cb71a310
5 changed files with 721 additions and 0 deletions

View File

@@ -145,6 +145,7 @@ FMT / ARGS are passed to `format'."
(require 'ox-publish)
(require 'cl-lib)
(require 'json)
(require 'org)
(require 'ox)
(require 'ox-html)
@@ -339,6 +340,47 @@ Created with %c on <a href=\"https://www.archlinux.org/\">Arch</a> \
slug
(file-name-base file)))))
(defun z/comment-page-url (file)
"Return root-relative published HTML URL for source FILE."
(concat "/"
(file-name-sans-extension
(file-relative-name file z/site-root))
".html"))
(defun z/comment-page-title (file)
"Return exported page title for FILE, or the file basename."
(with-temp-buffer
(insert-file-contents file nil 0 4096)
(goto-char (point-min))
(if (re-search-forward "^#\\+TITLE:[ \t]*\\(.+?\\)[ \t]*$" nil t)
(match-string 1)
(file-name-base file))))
(defun z/comment-page-record (file)
"Return a JSON-ready comment page record for FILE."
`((slug . ,(z/comments-file-slug file))
(title . ,(z/comment-page-title file))
(url . ,(z/comment-page-url file))))
(defun z/generate-comment-pages-json ()
"Write a slug-to-page manifest for comment-enabled Org files."
(let* ((files (directory-files-recursively z/site-root "\\.org\\'"))
(records
(cl-loop for file in files
unless (or (string-prefix-p (site-path "output/") file)
(string-prefix-p (site-path "backups/") file)
(string-prefix-p (site-path ".org-timestamps/") file)
(string-prefix-p (site-path ".packages/") file))
when (z/comments-file-p file)
collect (z/comment-page-record file)))
(target (site-path "assets/content/comment-pages.json"))
(json-encoding-pretty-print t))
(make-directory (file-name-directory target) t)
(with-temp-file target
(insert (json-encode (vconcat records)))
(insert "\n"))
(z/log 'done "Wrote comment page manifest (%d pages)" (length records))))
(defun z/org-html-insert-comments-into-body (body backend info)
"Append a comments section to BODY for files that opt in."
(when (org-export-derived-backend-p backend 'html)
@@ -760,6 +802,13 @@ A nil result means the timestamp cache is stale and we must force-republish."
(z/log 'error "Tag generation failed: %s" (error-message-string err))
(error "Aborting build: tag generation error"))))
(z/with-timing "comment page manifest"
(condition-case err
(z/generate-comment-pages-json)
(error
(z/log 'error "Comment page manifest failed: %s" (error-message-string err))
(error "Aborting build: comment page manifest error"))))
;; ─────────────────────────────────────────────────────────────────────────────
;; 16. Publish
;; ─────────────────────────────────────────────────────────────────────────────