Sort posts on blog index by date

This commit is contained in:
Jeremy Dormitzer 2019-06-12 18:13:14 -04:00
parent 7c54132915
commit 3098975214
2 changed files with 12 additions and 2 deletions

View File

@ -3,6 +3,7 @@
(require pollen/core
pollen/pagetree
pollen/file
gregor
racket/path
racket/list)
@ -14,7 +15,9 @@
(current-pagetree ptree)
(define (get-posts)
(children 'blog))
(sort (children 'blog)
date>?
#:key post-published-date))
(define (render-post post)
(let ((src (get-source (path->string (path->complete-path (symbol->string post))))))

View File

@ -11,6 +11,13 @@
(define (list-range lst start end)
(take (drop lst start) (- end start)))
(define (post->source post)
(get-source (path->string (path->complete-path (symbol->string post)))))
(define (post-published-date post)
(let ((src (post->source post)))
(iso8601->date (select-from-metas 'published src))))
(define (root . elements)
(let ((the-title (select-from-metas 'title (current-metas)))
(published (select-from-metas 'published (current-metas))))
@ -75,7 +82,7 @@
(txexpr 'div '((class "excerpt")) (list-range elts 2 5))))
(define (excerpt post)
(let ((src (get-source (path->string (path->complete-path (symbol->string post))))))
(let ((src (post->source post)))
(if (select-from-metas 'excerpt src)
(select-from-metas 'excerpt src)
(make-excerpt (get-doc src)))))