blog: Update tag list only for published posts
authorLucian Mogosanu <lucian.mogosanu@gmail.com>
Tue, 26 Feb 2019 18:51:45 +0000 (20:51 +0200)
committerLucian Mogosanu <lucian.mogosanu@gmail.com>
Tue, 26 Feb 2019 18:52:22 +0000 (20:52 +0200)
blog.lisp
templates/post.lisp

index cd64966..e0e3e5b 100644 (file)
--- a/blog.lisp
+++ b/blog.lisp
              (blist (tlbs-make-blist relative-pathname))
              (in-path (gethash "in-path" blist))
              (out-path (gethash "out-path" blist)))
-        ;; process tags
-        (when (not draft) (tlbs-make-tagids blist))
+        ;; process tags; update tag list with post when we're publishing
+        ;; the post.
+        (tlbs-make-tagids blist :update-tlist (not draft))
         (when (file-modified in-path out-path)
             (format t "[proc] ~s~%" x)
             ;; markdown -> html
index 9252a97..76ef5dc 100644 (file)
           ; add new tlist
           (push tlist *tags*)))))
 
-(defun tlbs-make-tagids (blist)
+(defun tlbs-make-tagids (blist &key (update-tlist t))
   (let ((new-tags
          (cl-ppcre:split "\\s*,\\s*" (gethash "tags" blist))))
     ; set tagid list in blist
     (setf (gethash "tags" blist) new-tags)
     ; as a side effect, adjoin a potential new tlist to the tag list
-    (dolist (tagid new-tags)
-      (adjoin-tagid tagid blist)))
+    (when update-tlist
+      (dolist (tagid new-tags)
+        (adjoin-tagid tagid blist))))
   blist)
 
 (defun pipe-through-pandoc (blist)