Implement blog index page

This commit is contained in:
Jeremy Dormitzer 2019-06-11 07:59:08 -04:00
parent e99a3ba3ba
commit e922d447d6
2 changed files with 26 additions and 4 deletions

View File

@ -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...}
}
}
}

View File

@ -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)))))