From 473868946feab62cf5f73e4ef93a85b54e40c358 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Tue, 12 Apr 2016 14:30:54 -0500 Subject: 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. --- haunt/post.scm | 12 +++++++----- 1 file 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 +;;; Copyright © 2016 Christopher Allan Webber ;;; ;;; 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 -- cgit v1.2.3