chore: small refactorings

This commit is contained in:
Gosha Tcherednitchenko 2024-02-21 16:56:24 +00:00
parent e532cc9afb
commit 8456557dfe
5 changed files with 20 additions and 13 deletions

View File

@ -5,9 +5,9 @@
:depends-on (#:cl-markdown)
:components ((:module "src"
:components
((:file "main")
(:file "templates")
(:file "util"))))
((:file "util")
(:file "templates" :depends-on ("util"))
(:file "main" :depends-on ("util" "templates")))))
:description "A static website generator"
:in-order-to ((test-op (test-op "homestead/tests"))))

View File

@ -2,3 +2,5 @@
<p>This is a test for the site homepage.</p>
<hr />
<p>This should get rendered in the middle of a layout.</p>
<p>{{ (include "footer.html") }}</p>
<p>Copyright 2024!</p>

View File

@ -1,6 +1,5 @@
(defpackage homestead
(:use #:cl)
(:local-nicknames (#:util #:homestead/util)))
(:use #:cl))
(in-package :homestead)
(defparameter *allowed-extensions* '("html" "md"))
@ -13,10 +12,11 @@
(defun load-content-file (full-permalink)
"Load the contents of the file at FULL-PERMALINK and return as string"
"test")
full-permalink)
(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)
(let* ((attributes (cadr node))

View File

@ -1,18 +1,21 @@
(defpackage homestead/templates
(:use #:cl))
(:use #:cl)
(:export #:render #:include))
(in-package :homestead/templates)
;;; Templates are rendered in a html file as such:
;;;
;;; <div>
;;; <%= (include "footer") %>
;;; {{ (include "footer") }}
;;; </div>
;;;
;;; This will look in the _includes directory for a file named footer.html or
;;; footer.md (or any allowed extension.)
(defun render ()
"Render a full or partial template")
(defun render (template)
"Render a full or partial template"
template)
(defun include ()
"Include a partial template at the location of the call")
(defun include (filename)
"Include a partial template at the location of the call"
filename)

View File

@ -1,6 +1,8 @@
(defpackage homestead/util
(:nicknames #:util)
(:use #:cl)
(:export #:join))
(in-package :homestead/util)
(defun join (list &optional (separator ", "))