diff options
author | David Thompson <dthompson2@worcester.edu> | 2024-10-31 14:01:53 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2024-10-31 14:05:13 -0400 |
commit | 00397d0a5707c85e6054a4d64b0520f1e1f96e93 (patch) | |
tree | 852751bc03eeba53fb8bffd1d858b92b7834e875 | |
parent | 2b8268683ad2406b38500cde18210100df67b745 (diff) |
flat-pages: Pass page metadata to template procedure.
This is a backwards incompatible change.
-rw-r--r-- | doc/haunt.texi | 6 | ||||
-rw-r--r-- | haunt/builder/flat-pages.scm | 10 |
2 files changed, 6 insertions, 10 deletions
diff --git a/doc/haunt.texi b/doc/haunt.texi index 0ac016f..2d82c8d 100644 --- a/doc/haunt.texi +++ b/doc/haunt.texi @@ -934,17 +934,13 @@ arguments: @itemize @item the site object -@item the page title string (from the metadata header) +@item the page metadata association list @item an SXML tree of the page body @end itemize @var{template} should return a single value: a new SXML tree representing a complete HTML page that presumably wraps the page body. -Conveniently, the signature of @var{template} matches the blog theme -layout procedure so that it can be reused for flat pages. @xref{Blog} -for more information. - The structure of @var{directory} is preserved in the resulting pages and may be optionally nested within the directory @var{prefix}. If no prefix is specified, the files are placed starting at the root of the diff --git a/haunt/builder/flat-pages.scm b/haunt/builder/flat-pages.scm index 85b3b53..3058c9a 100644 --- a/haunt/builder/flat-pages.scm +++ b/haunt/builder/flat-pages.scm @@ -35,11 +35,12 @@ #:use-module (srfi srfi-11) #:export (flat-pages)) -(define (ugly-page-template site title body) +(define (ugly-page-template site metadata body) `((doctype "html") (head (meta (@ (charset "utf-8"))) - (title ,(string-append title " — " (site-title site)))) + (title ,(string-append (or (assq-ref metadata 'title) "Untitled") + " — " (site-title site)))) (body (h1 ,(site-title site)) ,body))) @@ -80,8 +81,7 @@ complete HTML page that presumably wraps the page body." (#f (error "no reader available for page" file-name)) (reader (let-values (((metadata body) (reader-read reader file-name))) - (let* ((title (or (assq-ref metadata 'title) "Untitled")) - (index? (equal? (assq-ref metadata 'index) "true")) + (let* ((index? (equal? (assq-ref metadata 'index) "true")) (dir (substring (dirname file-name) (string-length directory))) (out (string-append prefix dir @@ -89,6 +89,6 @@ complete HTML page that presumably wraps the page body." (strip-extension file-name) (if index? "/index" "") ".html"))) - (serialized-artifact out (template site title body) + (serialized-artifact out (template site metadata body) sxml->html)))))) src-files))) |