summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2016-04-12 14:30:54 -0500
committerDavid Thompson <dthompson2@worcester.edu>2016-04-12 17:19:31 -0400
commit473868946feab62cf5f73e4ef93a85b54e40c358 (patch)
tree891cdf817865326ddea994014693680344cbf6a0
parent643b81ebbba880f834cd619a8a56304b938673ce (diff)
post: Allow posts to set their own slugs.
* haunt/post.scm (post-slug): Allow posts to set their own slug field and use that if available. Otherwise default to previous title-derived slug behavior.
-rw-r--r--haunt/post.scm12
1 files changed, 7 insertions, 5 deletions
diff --git a/haunt/post.scm b/haunt/post.scm
index 90a397c..56d0265 100644
--- a/haunt/post.scm
+++ b/haunt/post.scm
@@ -1,5 +1,6 @@
;;; Haunt --- Static site generator for GNU Guile
;;; Copyright © 2015 David Thompson <davet@gnu.org>
+;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
;;;
;;; This file is part of Haunt.
;;;
@@ -61,11 +62,12 @@
(define (post-slug post)
"Transform the title of POST into a URL slug."
- (string-join (map (lambda (s)
- (string-filter char-set:slug s))
- (string-split (string-downcase (post-ref post 'title))
- char-set:whitespace))
- "-"))
+ (or (post-ref post 'slug)
+ (string-join (map (lambda (s)
+ (string-filter char-set:slug s))
+ (string-split (string-downcase (post-ref post 'title))
+ char-set:whitespace))
+ "-")))
(define %default-date
(make-date 0 0 0 0 1 1 1970 0)) ; UNIX epoch