diff options
| author | Jakob L. Kreuze | 2019-05-17 11:35:26 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze | 2019-05-17 11:56:59 -0400 |
| commit | 2b9135189868fb45d00daa0a75b095bd8884d611 (patch) | |
| tree | c16c90e65a841bd213fbb9c4cc1e6237d035a3ea | |
| parent | 8c9b56ea3dc1570cd2cda741f75ee2e2dda85b31 (diff) | |
Refactor out 'make-slug
| -rw-r--r-- | haunt/haunt.scm | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/haunt/haunt.scm b/haunt/haunt.scm index 73c94f2..5e6fd52 100644 --- a/haunt/haunt.scm +++ b/haunt/haunt.scm @@ -31,6 +31,22 @@ (srfi srfi-26) (ice-9 match)) +(define (static-page title slug) + "Return a procedure serving statically-defined SXML." + (lambda (site posts) + (let ((file-name (format #f "~a.html" slug)) + (body (load (format #f "~a.scm" slug)))) + (make-page file-name + (with-layout jakob-theme site title body) + sxml->html)))) + +(define (make-slug post) + "Create a post slug from the source's filename." + (let* ((file-name (post-file-name post)) + (splice-start (1+ (string-rindex file-name (cut char=? <> #\/)))) + (splice-end (string-rindex file-name (cut char=? <> #\.)))) + (substring file-name splice-start splice-end))) + ;; Use a temporary reader until my patch makes it into an upstream release. (define (read-html-post-prime port) (values (read-metadata-headers port) @@ -56,14 +72,6 @@ (register-metadata-parser! 'date org-string->date) -(define (static-page title slug) - (lambda (site posts) - (let ((file-name (format #f "~a.html" slug)) - (body (load (format #f "~a.scm" slug)))) - (make-page file-name - (with-layout jakob-theme site title body) - sxml->html)))) - (define %collections `(("Recent Posts" "index.html" ,posts/reverse-chronological))) @@ -112,14 +120,7 @@ #:default-metadata '((author . "Jakob L. Kreuze") (email . "zerodaysfordays@sdf.lonestar.org")) - #:make-slug (lambda (post) - (let* ((file-name (post-file-name post)) - (splice-start (+ (string-rindex file-name - (cut char=? <> #\/)) - 1)) - (splice-end (string-rindex file-name - (cut char=? <> #\.)))) - (substring file-name splice-start splice-end))) + #:make-slug make-slug #:readers (list html-reader-prime) #:builders (list (blog #:theme jakob-theme #:collections %collections) (article-aliases %aliases) |