diff options
-rw-r--r-- | doc/haunt.texi | 4 | ||||
-rw-r--r-- | haunt/builder/flat-pages.scm | 19 |
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"))) |