aboutsummaryrefslogtreecommitdiff
path: root/ennum.el
diff options
context:
space:
mode:
Diffstat (limited to 'ennum.el')
-rw-r--r--ennum.el41
1 files changed, 26 insertions, 15 deletions
diff --git a/ennum.el b/ennum.el
index 8d99098..14b0533 100644
--- a/ennum.el
+++ b/ennum.el
@@ -136,6 +136,10 @@ respectively by - and _, and the pad character = is optional."
summary tags thumbnail title translation-group translations
video-posters)
+(cl-defstruct (ennum-link (:constructor ennum-make-link)
+ (:copier nil))
+ type path)
+
(defun ennum-posts (posts-directory)
(sort (seq-mapcat
;; Set translations slot of post objects.
@@ -190,7 +194,9 @@ respectively by - and _, and the pad character = is optional."
(`(link ,properties . ,_)
(let ((link-type (org-element-property :type link)))
(when (member link-type (list "image" "static" "video"))
- (cons link-type (org-element-property :path link))))))))))
+ (ennum-make-link
+ :type (intern link-type)
+ :path (org-element-property :path link))))))))))
(ennum-make-post
:filename filename
:slug (file-name-base filename)
@@ -214,17 +220,19 @@ respectively by - and _, and the pad character = is optional."
:tags (plist-get metadata :filetags)
:thumbnail (or (plist-get metadata :thumbnail)
(seq-some (lambda (link)
- (pcase link
- (`("image" . ,path) path)
- (`("video" . ,path) (ennum-video-poster path))))
+ (let ((path (ennum-link-path link)))
+ (pcase (ennum-link-type link)
+ ('image path)
+ ('video (ennum-video-poster path)))))
links))
:title (funcall export (first (plist-get metadata :title)))
:translation-group (or (plist-get metadata :translation-group)
(file-name-base filename))
:video-posters (ennum--filter-map (lambda (link)
- (pcase link
- (`("video" . ,path)
- `(,path . ,(ennum-video-poster path)))))
+ (pcase (ennum-link-type link)
+ ('video
+ (let ((path (ennum-link-path link)))
+ `(,path . ,(ennum-video-poster path))))))
links))))))
(defvar ennum-mandatory-metadata
@@ -521,23 +529,26 @@ if DESTINATION already exists."
(seq-filter 'identity (seq-map function sequence)))
(defun ennum-publish-link (link)
- (pcase link
- (`("image" . ,path)
+ (pcase (ennum-link-type link)
+ ('image
(seq-map (lambda (width)
(ennum-publish-image
- (ennum--expand-relative path (ennum-setting :images-directory))
+ (ennum--expand-relative (ennum-link-path link)
+ (ennum-setting :images-directory))
width))
(list (ennum-setting :default-image-width)
(ennum-setting :image-link-width))))
- (`("static" . ,path)
+ ('static
(list
(ennum-publish-copy
- (ennum--expand-relative path (ennum-setting :static-directory)))))
- (`("video" . ,path)
+ (ennum--expand-relative (ennum-link-path link)
+ (ennum-setting :static-directory)))))
+ ('video
(seq-map 'ennum-publish-copy
(list
- (ennum--expand-relative path (ennum-setting :video-directory))
- (ennum--expand-relative (ennum-video-poster path)
+ (ennum--expand-relative (ennum-link-path link)
+ (ennum-setting :video-directory))
+ (ennum--expand-relative (ennum-video-poster (ennum-link-path link))
(ennum-setting :images-directory)))))))
(defmacro ennum-with-current-directory (directory &rest body)