Skip to content
Snippets Groups Projects

Add support for content/*.lisp files as well as content/*.html

Closed Dave Cooper requested to merge dcooper/cl-site:master into master
1 file
+ 18
9
Compare changes
  • Side-by-side
  • Inline
+ 18
9
@@ -12,9 +12,9 @@
when (string= line "---") return lines
collect line into lines)))
(loop for line = (read-line f nil)
collect line into lines
unless line
return (values header-lines lines)))))
return (values header-lines lines)
collect line into lines))))
;; Copies/renders static assets (imgs, etc)
(defun process-static ()
@@ -33,6 +33,14 @@
;; process-pages : Copies/renders pages - called last
(defun render-template (template &optional context output-stream)
(let ((mustache:*load-path* (cons *PAGES-DIR* mustache:*load-path*))
(mustache:*default-pathname-type* "html"))
(mustache:render template context output-stream)))
(defun render-template* (template &optional context)
(with-output-to-string (output-stream)
(render-template template context output-stream)))
(defun render-page (page template-path)
(let ((page-path (make-path *PAGES-DIR* page t))
@@ -44,14 +52,15 @@
(content-text (format nil "~{~A~%~}" (remove nil content)))
(parsed-header (yaml:parse header-text))
(page-context
(when parsed-header
(loop for k being each hash-key of parsed-header
using (hash-value v)
collect (cons k v)))))
(when parsed-header
(loop for k being each hash-key of parsed-header
using (hash-value v)
collect (cons k v)))))
(with-open-file (output-stream output-path
:direction :output
:if-exists :supersede)
(mustache:render template-path (append (acons :page-content content-text page-context) *GLOBAL-CONTEXT*)
:direction :output
:if-exists :supersede)
(render-template template-path
(append (acons :page-content (render-template* content-text) page-context) *GLOBAL-CONTEXT*)
output-stream))))))
Loading