oxaliq.net/source/make-index.scm

65 lines
2.6 KiB
Scheme

(lambda (res posts)
(let ([article
`(article
,(cond
[(equal? res "settled")
'(hgroup (h1 "settled* thoughts")
(p (em "*-ish, something like a portfolio of projects")))]
[(equal? res "unsettled")
'(hgroup (h1 "unsettled thoughts")
(p (em "just doing some thinking aloud")))]
;; if res is tagged, build index of tags
[(equal? res "tagged")
'(hgroup (h1 "all the tags")
(p (em "a categorical mess for your perusal")))]
[(string-prefix? res "tagged/")
(let ([tag (string-replace res "tagged/" "#")])
`(hgroup (h1 "stuff what's tagged like " (em ,tag))
(p (em "everything (or maybe just some things) i've ever said about " (strong ,tag)))))]
[else
'(hgroup (h1 "i'm lost")
(p (em "you weren't meant to be here")))])
(h3 "the thoughts"))])
(define (settled-post post)
`((div ((class "post-preview"))
(h4 ,(second post))
(p ,(third post))
(a ((href ,(~a "/settled/" (first post))))
,(~a "go! to " (second post) " page")))))
(define (unsettled-post post)
`((div ((class "post-preview"))
(h4 ,(second post))
(p ,(third post))
(a ((href ,(~a "/unsettled/" (first post))))
,(~a "go! to " (second post) " page")))))
(define (tag-post post)
`((div ((class "post-preview"))
(h4 ,(~a post))
(p ,(~a "posts about " post))
(a ((href ,(~a "/tagged/" post)))
,(~a "go! to " post " page")))))
(define (tagged-post post)
`((div ((class "post-preview"))
(h4 ,(second post))
(p ,(third post))
;; tagged posts will insert href instead of id
(a ((href ,(~a "/" (first post))))
,(~a "go! to " (second post) " page")))))
(if
(< 0 (length posts))
(for-each
(lambda (post)
(set! article
(append article
(cond
[(equal? res "settled") (settled-post post)]
[(equal? res "unsettled") (unsettled-post post)]
[(equal? res "tagged") (tag-post post)]
[(string-prefix? res "tagged/") (tagged-post post)]))))
posts)
(set! article
(append article
`((p "there's nothing here yet")))))
article))