Skip to content

Commit b8e61c2

Browse files
author
Adam Simpson
committed
feat: add support for linked posts
1 parent c92d6bf commit b8e61c2

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

cycle.lisp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@
3737
(mapcar #'parse-post struct)))
3838

3939
(defun parse-post (post)
40-
"Convert json data to list."
41-
(let ((json (uiop:read-file-string (car (cdr post)))))
42-
(json:decode-json-from-string json)))
40+
"Create list that contains the data from each JSON file combined with the body of every post."
41+
(let* ((json (uiop:read-file-string (car (cdr post))))
42+
(list-json (json:decode-json-from-string json)))
43+
`(,@list-json (:content . ,(post-for-slug (cdr (assoc :slug list-json)))))))
4344

4445
(defun full-path-as-string (dir)
4546
(namestring (truename dir)))
@@ -88,18 +89,19 @@
8889
post
8990
rendered)
9091
(dolist (pair posts)
91-
(setf post (post-for-slug (cdr (assoc :slug pair))))
92-
(setf rendered (mustache:render* template `((:content . ,post)
93-
(:pub_date . ,(cdr (assoc :published pair)))
94-
(:mod_date . ,(cdr (assoc :modified pair)))
95-
(:modifiedDate . ,(parse-date (cdr (assoc :modified pair))))
96-
(:formattedDate . ,(parse-date (cdr (assoc :published pair))))
97-
(:link . ,(cdr (assoc :slug pair)))
98-
(:description . ,(cdr (assoc :excerpt pair)))
99-
(:slug . ,(concat "/writing/"
100-
(cdr (assoc :slug pair))))
101-
(:css . ,css)
102-
(:title . ,(cdr (assoc :title pair))))))
92+
(setf post `((:content . ,(cdr (assoc :content pair)))
93+
(:pub_date . ,(cdr (assoc :published pair)))
94+
(:mod_date . ,(cdr (assoc :modified pair)))
95+
(:modifiedDate . ,(parse-date (cdr (assoc :modified pair))))
96+
(:formattedDate . ,(parse-date (cdr (assoc :published pair))))
97+
(:link . ,(cdr (assoc :link pair)))
98+
(:description . ,(cdr (assoc :excerpt pair)))
99+
(:slug . ,(concat "/writing/"
100+
(cdr (assoc :slug pair))))
101+
(:css . ,css)
102+
(:title . ,(cdr (assoc :title pair)))))
103+
104+
(setf rendered (mustache:render* template post))
103105
(write-file rendered (concat
104106
"site/writing/"
105107
(cdr (assoc :slug pair))

0 commit comments

Comments
 (0)