|
37 | 37 | (mapcar #'parse-post struct))) |
38 | 38 |
|
39 | 39 | (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))))))) |
43 | 44 |
|
44 | 45 | (defun full-path-as-string (dir) |
45 | 46 | (namestring (truename dir))) |
|
88 | 89 | post |
89 | 90 | rendered) |
90 | 91 | (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)) |
103 | 105 | (write-file rendered (concat |
104 | 106 | "site/writing/" |
105 | 107 | (cdr (assoc :slug pair)) |
|
0 commit comments