Implement blog index page
This commit is contained in:
parent
e99a3ba3ba
commit
e922d447d6
@ -14,10 +14,13 @@
|
||||
◊(define (get-posts)
|
||||
(children 'blog))
|
||||
|
||||
◊title{}
|
||||
|
||||
◊for/splice[((post (get-posts)))]{
|
||||
◊let[((src (get-source (path->string (path->complete-path (symbol->string post))))))]{
|
||||
◊link[#:href (symbol->string post)]{◊section{◊(select 'h1 src)}}
|
||||
◊div{
|
||||
◊title{◊(select 'h1 src)}
|
||||
◊published-date[(select-from-metas 'published src)]
|
||||
◊excerpt[post]
|
||||
◊link[#:href (symbol->string post)]{Read more...}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,16 @@
|
||||
#lang racket
|
||||
(require pollen/core pollen/decode txexpr gregor)
|
||||
|
||||
(require pollen/core
|
||||
pollen/file
|
||||
pollen/decode
|
||||
txexpr
|
||||
gregor)
|
||||
|
||||
(provide (all-defined-out))
|
||||
|
||||
(define (list-range lst start end)
|
||||
(take (drop lst start) (- end start)))
|
||||
|
||||
(define (root . elements)
|
||||
(let ((the-title (select-from-metas 'title (current-metas)))
|
||||
(published (select-from-metas 'published (current-metas))))
|
||||
@ -59,3 +68,13 @@
|
||||
(let ((publish-date (iso8601->date date-str)))
|
||||
(txexpr
|
||||
'span '((class "published-date")) `("Posted on " ,(~t publish-date "MMMM d, y")))))
|
||||
|
||||
(define (make-excerpt doc)
|
||||
(let ((elts (get-elements doc)))
|
||||
(txexpr 'div '((class "excerpt")) (list-range elts 2 5))))
|
||||
|
||||
(define (excerpt post)
|
||||
(let ((src (get-source (path->string (path->complete-path (symbol->string post))))))
|
||||
(if (select-from-metas 'excerpt src)
|
||||
(select-from-metas 'excerpt src)
|
||||
(make-excerpt (get-doc src)))))
|
||||
|
Loading…
Reference in New Issue
Block a user