diff --git a/build-site.el b/build-site.el index e23ee62..368a529 100755 --- a/build-site.el +++ b/build-site.el @@ -173,13 +173,28 @@ FMT / ARGS are passed to `format'." (setq org-html-htmlize-output-type 'css) +(defun z/asset-version (path) + "Return a cache-busting version string for asset PATH under `z/site-root'." + (let* ((file (site-path path)) + (attrs (and (file-exists-p file) (file-attributes file))) + (mtime (and attrs (file-attribute-modification-time attrs))) + (size (and attrs (file-attribute-size attrs)))) + (if (and mtime size) + (format "%x-%x" (floor (float-time mtime)) size) + (format "%x" (floor z/build-start-time))))) + +(defun z/asset-url (path) + "Return root-relative asset PATH with a deterministic cache-busting query." + (format "/%s?v=%s" path (z/asset-version path))) + (defvar z/shared-head (concat "\n" (mapconcat (lambda (f) - (format "" f)) + (format "" + (z/asset-url (format "assets/styles/%s" f)))) '("style.css" "bigger-picture.min.css" "comments.css" @@ -194,7 +209,8 @@ FMT / ARGS are passed to `format'." "\n" (mapconcat (lambda (f) - (format "" f)) + (format "" + (z/asset-url (format "assets/scripts/%s" f)))) '("script.js" "lunr.js" "competency-status-board.js" @@ -209,7 +225,7 @@ FMT / ARGS are passed to `format'." "zhd.js" ) "\n") - " + (format " " + (z/asset-url "assets/scripts/mermaid.min.js")) ) "Shared HTML fragment injected into every page.") @@ -669,9 +686,8 @@ Created with %c on Arch \ (z/log 'info "Site output root : %s" z/output-root) (defun z/wipe-build-dirs () - "Delete output/, tags/, and .org-timestamps/ together." + "Delete output/ and .org-timestamps/ together." (dolist (dir (list z/output-root - (site-path "tags/") (site-path ".org-timestamps/"))) (if (file-directory-p dir) (progn @@ -699,7 +715,7 @@ A nil result means the timestamp cache is stale and we must force-republish." (cond ;; ── Explicit clean requested ─────────────────────────────────────────────── ((getenv "SITE_CLEAN") - (z/log 'warn "SITE_CLEAN=1 — wiping output/, tags/, and .org-timestamps/") + (z/log 'warn "SITE_CLEAN=1 — wiping output/ and .org-timestamps/") (z/wipe-build-dirs) (setenv "SITE_FORCE" "1")) @@ -743,14 +759,29 @@ A nil result means the timestamp cache is stale and we must force-republish." (z/log-separator "Publishing") +(defun z/sync-assets-to-output () + "Copy assets/ into the configured output assets directory, overwriting stale files." + (let ((source-root (site-path "assets/")) + (target-root (output-path "assets/"))) + (when (file-directory-p source-root) + (dolist (file (directory-files-recursively source-root ".*" nil)) + (unless (file-directory-p file) + (let* ((rel (file-relative-name file source-root)) + (target (expand-file-name rel target-root))) + (make-directory (file-name-directory target) t) + (copy-file file target t t t t))))))) + (if (getenv "SITE_DRY") (z/log 'warn "SITE_DRY=1 — skipping org-publish-all (dry run)") (let ((force (not (not (getenv "SITE_FORCE"))))) (when force (z/log 'info "SITE_FORCE=1 — forcing republish of all files")) (condition-case err - (z/with-timing "org-publish-all" - (org-publish-all force)) + (progn + (z/with-timing "org-publish-all" + (org-publish-all force)) + (z/with-timing "asset sync" + (z/sync-assets-to-output))) (error (z/log 'error "org-publish-all failed: %s" (error-message-string err)) (error "Build failed"))))) diff --git a/posts/posts-list.org b/posts/posts-list.org index 4072c0f..e286e6a 100755 --- a/posts/posts-list.org +++ b/posts/posts-list.org @@ -4,7 +4,7 @@ See the categories: @@html:Categories@@ * Posts: -- [[file:career/career-list.org][Career List]] @@html:09-05-2026 18:33@@ +- [[file:career/career-list.org][Career List]] @@html:09-05-2026 18:44@@ - [[file:career/ha-dr.org][High Availability, Disaster Recovery and Business Continuity]] @@html:11-03-2026 17:18@@ @@html:learning@@ @@html:notes@@ - [[file:career/javascript.org][Understands the Javascript language]] @@html:11-03-2026 16:52@@ @@html:learning@@ @@html:notes@@ - [[file:career/restful-api.org][Restful API]] @@html:15-02-2026 23:00@@ @@html:learning@@ @@html:notes@@ diff --git a/sitemap.org b/sitemap.org index 137ae51..d7637f6 100755 --- a/sitemap.org +++ b/sitemap.org @@ -49,17 +49,17 @@ - [[file:posts/career/ha-dr.org][High Availability, Disaster Recovery and Business Continuity]] - [[file:posts/career/career-list.org][Career List]] - tags - - [[file:tags/review.sync-conflict-20260328-203248-VT6366A.org][Tag: review]] - [[file:tags/life.sync-conflict-20260417-233423-VT6366A.org][Tag: life]] + - [[file:tags/review.sync-conflict-20260328-203248-VT6366A.org][Tag: review]] - [[file:tags/introduction.org][Tag: introduction]] - [[file:tags/learning.org][Tag: learning]] - [[file:tags/notes.org][Tag: notes]] - [[file:tags/review.org][Tag: review]] - [[file:tags/website.org][Tag: website]] - [[file:tags/update.org][Tag: update]] - - [[file:tags/insights.org][Tag: insights]] - [[file:tags/life.org][Tag: life]] - [[file:tags/education.org][Tag: education]] + - [[file:tags/insights.org][Tag: insights]] - [[file:tags/reading.org][Tag: reading]] - [[file:tags/emacs.org][Tag: emacs]] - [[file:tags/maths.org][Tag: maths]] \ No newline at end of file