diff options
Diffstat (limited to 'haunt/post.scm')
-rw-r--r-- | haunt/post.scm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/haunt/post.scm b/haunt/post.scm index d15efd2..fb8eaea 100644 --- a/haunt/post.scm +++ b/haunt/post.scm @@ -38,6 +38,7 @@ post-ref post-ref-all post-slug + post-slug-v2 %default-date post-date post-author @@ -80,6 +81,17 @@ char-set:whitespace)) "-"))) +(define char-set:slug-v2 char-set:letter+digit) +(define char-set:!slug-v2 (char-set-complement char-set:slug-v2)) + +(define (post-slug-v2 post) + "Transform the title of POST into a URL slug." + (or (post-ref post 'slug) + (string-join (remove string-null? + (string-split (string-downcase (post-title post)) + char-set:!slug-v2)) + "-"))) + (define %default-date (make-date 0 0 0 0 1 1 1970 0)) ; UNIX epoch |