chore: small refactorings
This commit is contained in:
parent
e532cc9afb
commit
8456557dfe
|
@ -5,9 +5,9 @@
|
||||||
:depends-on (#:cl-markdown)
|
:depends-on (#:cl-markdown)
|
||||||
:components ((:module "src"
|
:components ((:module "src"
|
||||||
:components
|
:components
|
||||||
((:file "main")
|
((:file "util")
|
||||||
(:file "templates")
|
(:file "templates" :depends-on ("util"))
|
||||||
(:file "util"))))
|
(:file "main" :depends-on ("util" "templates")))))
|
||||||
:description "A static website generator"
|
:description "A static website generator"
|
||||||
:in-order-to ((test-op (test-op "homestead/tests"))))
|
:in-order-to ((test-op (test-op "homestead/tests"))))
|
||||||
|
|
||||||
|
|
|
@ -2,3 +2,5 @@
|
||||||
<p>This is a test for the site homepage.</p>
|
<p>This is a test for the site homepage.</p>
|
||||||
<hr />
|
<hr />
|
||||||
<p>This should get rendered in the middle of a layout.</p>
|
<p>This should get rendered in the middle of a layout.</p>
|
||||||
|
<p>{{ (include "footer.html") }}</p>
|
||||||
|
<p>Copyright 2024!</p>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
(defpackage homestead
|
(defpackage homestead
|
||||||
(:use #:cl)
|
(:use #:cl))
|
||||||
(:local-nicknames (#:util #:homestead/util)))
|
|
||||||
(in-package :homestead)
|
(in-package :homestead)
|
||||||
|
|
||||||
(defparameter *allowed-extensions* '("html" "md"))
|
(defparameter *allowed-extensions* '("html" "md"))
|
||||||
|
@ -13,10 +12,11 @@
|
||||||
|
|
||||||
(defun load-content-file (full-permalink)
|
(defun load-content-file (full-permalink)
|
||||||
"Load the contents of the file at FULL-PERMALINK and return as string"
|
"Load the contents of the file at FULL-PERMALINK and return as string"
|
||||||
"test")
|
full-permalink)
|
||||||
|
|
||||||
(defun get-template (node)
|
(defun get-template (node)
|
||||||
"Get the appropriate template to render the NODE")
|
"Get the appropriate template to render the NODE"
|
||||||
|
(first node))
|
||||||
|
|
||||||
(defun process-metadata-node (node children full-permalink)
|
(defun process-metadata-node (node children full-permalink)
|
||||||
(let* ((attributes (cadr node))
|
(let* ((attributes (cadr node))
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
(defpackage homestead/templates
|
(defpackage homestead/templates
|
||||||
(:use #:cl))
|
(:use #:cl)
|
||||||
|
(:export #:render #:include))
|
||||||
(in-package :homestead/templates)
|
(in-package :homestead/templates)
|
||||||
|
|
||||||
;;; Templates are rendered in a html file as such:
|
;;; Templates are rendered in a html file as such:
|
||||||
;;;
|
;;;
|
||||||
;;; <div>
|
;;; <div>
|
||||||
;;; <%= (include "footer") %>
|
;;; {{ (include "footer") }}
|
||||||
;;; </div>
|
;;; </div>
|
||||||
;;;
|
;;;
|
||||||
;;; This will look in the _includes directory for a file named footer.html or
|
;;; This will look in the _includes directory for a file named footer.html or
|
||||||
;;; footer.md (or any allowed extension.)
|
;;; footer.md (or any allowed extension.)
|
||||||
|
|
||||||
(defun render ()
|
(defun render (template)
|
||||||
"Render a full or partial template")
|
"Render a full or partial template"
|
||||||
|
template)
|
||||||
|
|
||||||
(defun include ()
|
(defun include (filename)
|
||||||
"Include a partial template at the location of the call")
|
"Include a partial template at the location of the call"
|
||||||
|
filename)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
(defpackage homestead/util
|
(defpackage homestead/util
|
||||||
|
(:nicknames #:util)
|
||||||
(:use #:cl)
|
(:use #:cl)
|
||||||
(:export #:join))
|
(:export #:join))
|
||||||
|
|
||||||
(in-package :homestead/util)
|
(in-package :homestead/util)
|
||||||
|
|
||||||
(defun join (list &optional (separator ", "))
|
(defun join (list &optional (separator ", "))
|
||||||
|
|
Loading…
Reference in New Issue