Commit c9f6d60b authored by Erik Huelsmann's avatar Erik Huelsmann

Transform 'generate-news' into a page post-processing step

Now that we have pre-/post-processing and dependency tracking in place,
we have all the components we need to stop generating 'news' before the
rest of the site.

The above is nice, because we no longer need to encode site structure
knowledge into the site generator.
parent ae09ef38
......@@ -22,7 +22,6 @@
(format t "Generating site in ~A.~%" *output-dir*)
(process-static *static-dir* *output-dir*)
(process-static (merge-pathnames #P"static/" *layout-dir*) *output-dir*)
(loop for page in pages
for page-path = (make-path *pages-dir* page t)
......@@ -51,6 +50,7 @@
when satisfies-deps-p
do (preprocess-md-page content context
(list #'preprocess-lisp-page
(lambda (p c next-processors)
(process-page p c))))
collect rel-page-path into processed-pages
......@@ -64,6 +64,7 @@
(push (fourth delay) processed-pages)
(preprocess-md-page (second delay) (third delay)
(list #'preprocess-lisp-page
(lambda (p c next-processors)
(process-page p c))))))
while resolved-deps-pages
......@@ -106,23 +106,17 @@
;; newsbox. The news.lisp would have to include the hardcoded HTML
;; which is injected below as well.
(defun generate-news ()
(let ((html
(with-output-to-string (out) (cl-markdown:markdown (merge-pathnames "" *PAGES-DIR*) :stream out))))
(with-open-file (f (merge-pathnames "news.html" *PAGES-DIR*)
:direction :output
:if-does-not-exist :create
:if-exists :supersede)
(write-string "<div id=\"bodyText\">" f)
(format f "<a class=\"btn btn-secondary float-right\" href=\"~A\"><i class=\"far fa-edit\"></i>&nbsp;Edit this page</a>" +edit-news-link+)
(write-string "<h1>Latest news</h1>" f)
(write-string html f)
(write-string "</div>" f))
(with-open-file (f (merge-pathnames "newsbox.html" *PAGES-DIR*)
:direction :output
:if-does-not-exist :create
:if-exists :supersede)
(write-string (generate-news-box-content html) f))))
(defun generate-news (content context next-processors)
(let ((page-path (cdr (assoc :content context)))
(content (funcall (pop next-processors) content context next-processors)))
(when (and (string= (pathname-name page-path) "news")
(string= (pathname-type page-path) "md"))
(with-open-file (f (merge-pathnames "newsbox.html" *PAGES-DIR*)
:direction :output
:if-does-not-exist :create
:if-exists :supersede)
(write-string (generate-news-box-content content) f)))
(defun shallow-copy-object (original)
(let* ((class (class-of original))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment