diff --git a/lisp/build.el b/lisp/build.el
index b5be5c6..5529e81 100644
--- a/lisp/build.el
+++ b/lisp/build.el
@@ -11,12 +11,37 @@
(package-initialize)
(defvar site-root
- (file-name-directory
- (or load-file-name buffer-file-name)))
+ (let ((script-dir (file-name-directory
+ (or load-file-name buffer-file-name))))
+ (file-name-as-directory
+ (expand-file-name
+ (if (string= (file-name-nondirectory
+ (directory-file-name script-dir))
+ "lisp")
+ ".."
+ ".")
+ script-dir))))
+
+(defconst z/build-start-time (float-time)
+ "Wall-clock time when the build started.")
(defun site-path (path)
(expand-file-name path site-root))
+(defun z/asset-version (path)
+ "Return a deterministic cache-busting version for asset PATH."
+ (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 cache-busting query string."
+ (format "/%s?v=%s" path (z/asset-version path)))
+
(unless package-archive-contents
(package-refresh-contents))
@@ -138,26 +163,41 @@
(add-to-list 'load-path default-directory)
(defvar z-shared-head
- "
-
+ (concat
+ "\n
-
-
-
-
+"
+ (mapconcat
+ (lambda (file)
+ (format ""
+ (z/asset-url (format "assets/styles/%s" file))))
+ '("style.css"
+ "bigger-picture.min.css"
+ "media.css"
+ "cookbook.css")
+ "\n")
+ "
-
-
-
-
-
-
-
-
+"
+ (mapconcat
+ (lambda (file)
+ (format ""
+ (z/asset-url (format "assets/scripts/%s" file))))
+ '("script.js"
+ "search.js"
+ "bigger-picture.min.js"
+ "svg-pan-zoom.min.js"
+ "gallery-init.js"
+ "cookbook.js")
+ "\n")
+ "\n\n"
+ (format ""
+ (z/asset-url "assets/scripts/mermaid.min.js"))
+ "
-"
+")
)
(defvar z-preamble