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.
This commit is contained in:
Christopher Allan Webber 2016-04-12 14:30:54 -05:00 committed by David Thompson
parent 643b81ebbb
commit 473868946f
1 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,6 @@
;;; Haunt --- Static site generator for GNU Guile ;;; Haunt --- Static site generator for GNU Guile
;;; Copyright © 2015 David Thompson <davet@gnu.org> ;;; Copyright © 2015 David Thompson <davet@gnu.org>
;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
;;; ;;;
;;; This file is part of Haunt. ;;; This file is part of Haunt.
;;; ;;;
@ -61,11 +62,12 @@
(define (post-slug post) (define (post-slug post)
"Transform the title of POST into a URL slug." "Transform the title of POST into a URL slug."
(string-join (map (lambda (s) (or (post-ref post 'slug)
(string-filter char-set:slug s)) (string-join (map (lambda (s)
(string-split (string-downcase (post-ref post 'title)) (string-filter char-set:slug s))
char-set:whitespace)) (string-split (string-downcase (post-ref post 'title))
"-")) char-set:whitespace))
"-")))
(define %default-date (define %default-date
(make-date 0 0 0 0 1 1 1970 0)) ; UNIX epoch (make-date 0 0 0 0 1 1 1970 0)) ; UNIX epoch