Make sure we render off the base template.
This commit is contained in:
parent
d571634677
commit
b92fb4d9b6
3 changed files with 34 additions and 15 deletions
|
@ -36,6 +36,24 @@ on files that match the given extension."
|
|||
(render-indices))
|
||||
(deploy staging)))
|
||||
|
||||
(defun render-page (path html)
|
||||
(ensure-directories-exist path)
|
||||
(with-open-file (out path
|
||||
:direction :output
|
||||
:if-does-not-exist :create)
|
||||
(let ((content (funcall (theme-fn "BASE")
|
||||
(list :title (title *config*)
|
||||
:siteroot (domain *config*)
|
||||
:navigation (sitenav *config*)
|
||||
:content html
|
||||
:head-inject (apply #'concatenate 'string
|
||||
(gethash :head *injections*))
|
||||
:body-inject (apply #'concatenate 'string
|
||||
(gethash :body *injections*))
|
||||
:license (license *config*)
|
||||
:credits (author *config*)))))
|
||||
(write content out))))
|
||||
|
||||
(defun update-symlink (name target)
|
||||
"Update the symlink NAME to point to TARGET."
|
||||
(run-program "ln" (list "-sfn" (namestring target) name)))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(in-package :coleslaw)
|
||||
|
||||
(defparameter *metadata* (make-hash-table :test #'equal))
|
||||
(defparameter *posts* (make-hash-table :test #'equal))
|
||||
|
||||
(defclass post ()
|
||||
((slug :initform nil :initarg :slug :accessor post-slug)
|
||||
|
@ -15,24 +15,22 @@
|
|||
(do-files (file (repo *config*) "post")
|
||||
(with-open-file (in file)
|
||||
(let ((post (read-post in)))
|
||||
(setf (gethash (post-slug post) *metadata*) post))))
|
||||
(maphash #'write-post *metadata*))
|
||||
(setf (gethash (post-slug post) *posts*) post))))
|
||||
(maphash #'write-post *posts*))
|
||||
|
||||
(defun read-post (stream)
|
||||
"Make a POST instance based on the data from STREAM."
|
||||
|
||||
(make-instance 'post
|
||||
:slug (make-slug post))
|
||||
)
|
||||
|
||||
(defun write-post (slug post)
|
||||
"Write out the HTML for POST in SLUG.html."
|
||||
(with-open-file (out (format nil "~a.html" slug)
|
||||
:direction :output
|
||||
:if-does-not-exist :create)
|
||||
(let ((content (funcall (theme-fn "POST")
|
||||
(render-page (format nil "~a.html" slug)
|
||||
(funcall (theme-fn "POST")
|
||||
(list :title (post-title post)
|
||||
:tags (post-tags post)
|
||||
:date (post-date post)
|
||||
:content (post-content post)
|
||||
:prev nil
|
||||
:next nil))))
|
||||
(write content out))))
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
(defun theme-package (&key (name (theme *config*)))
|
||||
(find-package (string-upcase (concatenate 'string "coleslaw.theme." name))))
|
||||
|
||||
(defun theme-fn (name)
|
||||
(find-symbol name (theme-package)))
|
||||
|
||||
(defun compile-theme (&key (theme-dir (app-path "themes/~a/" (theme *config*))))
|
||||
(do-files (file theme-dir "tmpl")
|
||||
(compile-template :common-lisp-backend file)))
|
||||
|
|
Loading…
Add table
Reference in a new issue