summaryrefslogtreecommitdiff
path: root/z.scm
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-05-09 22:31:30 -0700
committerBen Sima <ben@bsima.me>2020-05-09 22:31:30 -0700
commitd4db97edda778fbf77cedc89f62184f412f18edf (patch)
treed67196c22139e9aa63a612b52b1a93b565e9c502 /z.scm
parentfd721e94532ba7f912d13706b3c03056345952e6 (diff)
Add get-tags function
Diffstat (limited to 'z.scm')
-rw-r--r--z.scm26
1 files changed, 15 insertions, 11 deletions
diff --git a/z.scm b/z.scm
index 6e8972a..c318d9a 100644
--- a/z.scm
+++ b/z.scm
@@ -95,7 +95,7 @@
(define (cat-node id)
(prn (read-node id)))
-;; Indexing
+;; Metadata
(define (get-title id)
(-> id
@@ -103,17 +103,21 @@
(re.match "title: ([^\n]*)")
(match:substring 1)))
-(define (index-titles)
- (fold
- (lambda (node ls) (acons (get-title node) node ls))
- '()
- (list-nodes)))
-
(define (get-by-title title)
(let ([index (index-titles)])
(assoc title index)))
-(comment
- (define index-tags)
- (define index-links)
- )
+(define (get-tags id)
+ (-> id
+ read-node
+ (re.match "tags: ([^\n]*)")
+ (re.group 1)
+ (string.split #\space)))
+
+;; Indexing
+
+(define (index-titles)
+ (fold
+ (/. node ls (acons (get-title node) node ls))
+ '()
+ (list-nodes)))