post: Add post-ref-all procedure.
authorDavid Thompson <dthompson2@worcester.edu>
Mon, 19 Nov 2018 01:46:36 +0000 (20:46 -0500)
committerDavid Thompson <dthompson2@worcester.edu>
Mon, 19 Nov 2018 01:46:36 +0000 (20:46 -0500)
* haunt/post.scm (post-ref-all): New procedure.

haunt/post.scm

index 2b97629..0a0bb8d 100644 (file)
@@ -36,6 +36,7 @@
             post-sxml
             post-metadata
             post-ref
+            post-ref-all
             post-slug
             %default-date
             post-date
   "Return the metadata corresponding to KEY within POST."
   (assq-ref (post-metadata post) key))
 
+(define (post-ref-all post key)
+  "Return a list of all metadata values for KEY within POST."
+  (filter-map (match-lambda
+                ((k . v)
+                 (and (eq? key k) v)))
+              (post-metadata post)))
+
 (define char-set:slug
   (char-set-union char-set:letter+digit (char-set #\-)))