diff --git a/src/blog/index.html.pm b/src/blog/index.html.pm
index 00834dc..4cd6fbf 100644
--- a/src/blog/index.html.pm
+++ b/src/blog/index.html.pm
@@ -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))))))
diff --git a/src/pollen.rkt b/src/pollen.rkt
index f272e87..f3ac0f6 100644
--- a/src/pollen.rkt
+++ b/src/pollen.rkt
@@ -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)))))