|
@@ -22,10 +22,20 @@
|
22
|
22
|
(post-slug post))
|
23
|
23
|
(setf (gethash (post-slug post) *posts*) post))))))
|
24
|
24
|
|
|
25
|
+(defun post-url (post)
|
|
26
|
+ "Return the relative URL for a given post."
|
|
27
|
+ (format nil "posts/~a.html" (post-slug post)))
|
|
28
|
+
|
25
|
29
|
(defun render-posts ()
|
26
|
30
|
"Iterate through the files in the repo to render+write the posts out to disk."
|
27
|
31
|
(load-posts)
|
28
|
|
- (maphash #'write-post *posts*))
|
|
32
|
+ (loop with posts = (sort (hash-table-values *posts*) #'string< :key #'post-date)
|
|
33
|
+ for i from 1 upto (length posts)
|
|
34
|
+ for prev = nil then post
|
|
35
|
+ for post = (nth (1- i) posts)
|
|
36
|
+ for next = (nth (1+ i) posts)
|
|
37
|
+ do (write-post post :prev (and prev (post-url prev))
|
|
38
|
+ :next (and next (post-url next)))))
|
29
|
39
|
|
30
|
40
|
(defgeneric render-content (text format)
|
31
|
41
|
(:documentation "Compile TEXT from the given FORMAT to HTML for display.")
|
|
@@ -51,18 +61,17 @@
|
51
|
61
|
(append args (list :content (read-line in nil)
|
52
|
62
|
:slug (slugify (getf args :title))))))))
|
53
|
63
|
|
54
|
|
-(defun write-post (slug post)
|
|
64
|
+(defun write-post (post &key prev next)
|
55
|
65
|
"Write out the HTML for POST in SLUG.html."
|
56
|
|
- (render-page (format nil "posts/~a.html" slug)
|
|
66
|
+ (render-page (post-url post)
|
57
|
67
|
(funcall (theme-fn "POST")
|
58
|
68
|
(list :title (post-title post)
|
59
|
69
|
:tags (post-tags post)
|
60
|
70
|
:date (post-date post)
|
61
|
71
|
:content (render-content (post-content post)
|
62
|
72
|
(post-format post))
|
63
|
|
- ; TODO: Populate prev and next with links.
|
64
|
|
- :prev nil
|
65
|
|
- :next nil))))
|
|
73
|
+ :prev prev
|
|
74
|
+ :next next))))
|
66
|
75
|
|
67
|
76
|
(defun slug-char-p (char)
|
68
|
77
|
"Determine if CHAR is a valid slug (i.e. URL) character."
|