summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2024-09-24 10:34:36 -0400
committerDavid Thompson <dthompson2@worcester.edu>2024-09-24 10:34:36 -0400
commit1f07b6076ae3e35177f481efdc9107b6d4d0611a (patch)
tree4d7c23c055dd99886aed9fa1ae9ea922c676440c
parent0a7186155a65da5a95b21520f8d7f8f8e3a9bc12 (diff)
flat-pages: Set default directory, template, and prefix args.
-rw-r--r--doc/haunt.texi4
-rw-r--r--haunt/builder/flat-pages.scm19
2 files changed, 18 insertions, 5 deletions
diff --git a/doc/haunt.texi b/doc/haunt.texi
index 8df937a..acc7257 100644
--- a/doc/haunt.texi
+++ b/doc/haunt.texi
@@ -884,7 +884,9 @@ in some markup language to full web pages. Flat pages work great for
the more informational parts of a website that don't require any fancy
programming to generate, like an ``About me'' page.
-@deffn {Procedure} flat-pages directory [#:template] [#:prefix]
+@deffn {Procedure} flat-pages [directory "pages"] @@
+ [#:template ugly-page-template] @@
+ [#:prefix "/"]
Return a procedure that parses the files in @var{directory} and
returns a list of HTML pages, one for each file. The files are parsed
diff --git a/haunt/builder/flat-pages.scm b/haunt/builder/flat-pages.scm
index f04ecef..edf778a 100644
--- a/haunt/builder/flat-pages.scm
+++ b/haunt/builder/flat-pages.scm
@@ -35,9 +35,20 @@
#:use-module (srfi srfi-11)
#:export (flat-pages))
-(define* (flat-pages directory #:key
- template
- prefix)
+(define (ugly-page-template site title body)
+ `((doctype "html")
+ (head
+ (meta (@ (charset "utf-8")))
+ (title ,(string-append title " — " (site-title site))))
+ (body
+ (h1 ,(site-title site))
+ ,body)))
+
+(define* (flat-pages #:optional
+ (directory "pages")
+ #:key
+ (template ugly-page-template)
+ (prefix "/"))
"Return a procedure that parses the files in DIRECTORY and returns a
list of HTML pages, one for each file. The files are parsed using the
readers configured for the current site. The structure of DIRECTORY
@@ -71,7 +82,7 @@ complete HTML page that presumably wraps the page body."
(let-values (((metadata body) (reader-read reader file-name)))
(let* ((dir (substring (dirname file-name)
(string-length directory)))
- (out (string-append (or prefix "/") dir
+ (out (string-append prefix dir
(if (string-null? dir) "" "/")
(strip-extension file-name) ".html"))
(title (or (assq-ref metadata 'title) "Untitled")))