miniblog

Miniblog: A command-line static blog system in Common Lisp
Log | Files | Refs | README | LICENSE

commit db01facfd06e1e4cdbdcbb99c4ff7289ce049260
parent ab4596dab4eb6c2e72b377dd1f0144bb3465273a
Author: Decay <decaydjk@tilde.town>
Date:   Fri, 10 Apr 2020 12:22:00 -0700

Correctly regenerate the full archive whenever a new month is added

Diffstat:
Msrc/miniblog.lisp | 18+++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/miniblog.lisp b/src/miniblog.lisp @@ -87,6 +87,18 @@ :tz *blog-timezone*))) (mapcar #'regenerate-file all))) +(defun new-month-p (entries year month) + "Determine if there is only one entry in a given month and year" + (let ((entries-in-month + (remove-if + (lambda (entry) + (let* ((year-month (miniblog.content:year-month-of-entry entry)) + (entry-year (car year-month)) + (entry-month (cdr year-month))) + (not (and (eql year entry-year) (eql month entry-month))))) + entries))) + (eql (length entries-in-month) 1))) + (defun add-new (regen) (let ((text (miniblog.edit:edit-text))) (if text @@ -102,9 +114,9 @@ (year (car year-month)) (month (cdr year-month)) (entries (miniblog.db:get-entries))) - (if (not regen) - (regenerate-index-and-given-month entries year month) - (regenerate-all entries))) + (if (or regen (new-month-p entries year month)) + (regenerate-all entries) + (regenerate-index-and-given-month entries year month))) (format t "Abandoning post...~%")))) (defun date-format (datetime)