Indices should work now.

This commit is contained in:
Brit Butler 2012-08-20 12:06:01 -04:00
parent 2454656471
commit 67b3f26da3

View file

@ -12,13 +12,21 @@
collect (list :url (format nil "~a/month/~a.html" (domain *config*) month)
:name month))))
(defun render-index (posts)
(loop for post in posts
collect (list :url (format nil "~a/posts/~a.html"
(domain *config*) (post-slug post))
:title (post-title post)
:date (post-date post)
:contents (post-contents post))))
(defun write-index (posts filename)
(let ((content (loop for post in posts
collect (list :url (format nil "~a/posts/~a.html"
(domain *config*) (post-slug post))
:title (post-title post)
:date (post-date post)
:contents (post-contents post)))))
(render-page filename
(funcall (theme-fn "INDEX")
(list :taglinks (taglinks)
:monthlinks (monthlinks)
:posts content
; TODO: Populate prev and next with links.
:prev nil
:next nil)))))
(defun render-by-20 ()
(flet ((by-20 (posts start)
@ -27,14 +35,7 @@
(let ((posts (sort *posts* #'string> :key #'post-date)))
(loop for i from 1 then (1+ i)
until (> (* (1- i) 20) (length posts))
do (render-page (format nil "~d.html" i)
(funcall (theme-fn "INDEX")
(list :taglinks (taglinks)
:monthlinks (monthlinks)
:posts (render-index (by-20 posts i))
; TODO: Populate prev and next with links.
:prev nil
:next nil)))))))
do (write-index (by-20 posts i) (format nil "~d.html" i))))))
(defun render-by-tag ()
(let ((tags (remove-duplicates (mapcan #'post-tags *posts*) :test #'string=)))
@ -43,11 +44,17 @@
(member tag x :test #'string=
:key #'post-tags))
posts)))
(render-index posts)))))
(write-index posts (format nil "tag/~a.html" tag))))))
(defun render-by-month ())
(defun render-by-month ()
;; TODO: Make this actually work. Add to render-indices.
(let ((months (remove-duplicates (mapcar #'post-date *posts*) :test #'string=)))
(loop for month in months
do (let ((posts (remove-if-not (lambda (x)
(from-month month x)
posts))))
(render-index posts)))))
(defun render-indices ()
(render-by-20)
(render-by-tag)
(render-by-month))
(render-by-tag))