From b25a703572143b7f9cfc5f55704cd2c114b6adc3 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 1 Jul 2025 02:08:52 +0100 Subject: Support images generated at build-time. * ennum.el (ennum-setting): Add :generated-image-paths. (ennum--find-image): New function. (ennum-publish-link, ennum-publish): Use ennum--find-image. --- ennum.el | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/ennum.el b/ennum.el index 1526e48..6314a5c 100644 --- a/ennum.el +++ b/ennum.el @@ -673,7 +673,8 @@ result as a string." :locale-alist :other-files-directory :pdf-width :pdf-height :store :tag-directory :image-thumbnail-width - :required-metadata :other-items) + :required-metadata :generated-image-paths + :other-items) (plist-get (org-combine-plists (list :atom-feed-number-of-posts 12 :atom-feed-file "blog.atom" @@ -757,14 +758,21 @@ recognized as a directory, it should end in a slash. See (defun ennum--filter-map (function sequence) (seq-filter 'identity (seq-map function sequence))) +(defun ennum--find-image (path) + "Find store item for image with PATH." + (or (seq-find 'file-exists-p + (seq-map (apply-partially 'expand-file-name + path) + (ennum-setting :generated-image-paths))) + (ennum-intern (ennum--file-join (ennum-setting :images-directory) + path)))) + (defun ennum-publish-link (link) (pcase (ennum-link-type link) ('image (seq-map (lambda (width) - (ennum-publish-image - (ennum-intern (ennum--file-join (ennum-setting :images-directory) - (ennum-link-path link))) - width)) + (ennum-publish-image (ennum--find-image (ennum-link-path link)) + width)) (list (ennum-setting :image-width) (ennum-setting :image-link-width)))) ((or 'pdf 'static) @@ -850,10 +858,8 @@ as keys. Keys are compared using `equal'." (ennum-many-to-many-group-by 'ennum-post-tags posts)) ;; Publish thumbnails (seq-map (lambda (image) - (ennum-publish-image - (ennum-intern (ennum--file-join (ennum-setting :images-directory) - image)) - (ennum-setting :image-thumbnail-width))) + (ennum-publish-image (ennum--find-image image) + (ennum-setting :image-thumbnail-width))) (ennum--filter-map 'ennum-post-thumbnail posts)) ;; Publish other files (seq-map (apply-partially 'ennum-publish-generic other-files-directory) -- cgit v1.2.3