Commit ab2a63cf authored by Ludovic Courtès's avatar Ludovic Courtès

Summarize posts on the main blog page.

* haunt.scm (summarize-post): New procedure. (post->sxml): Add #:summarize? and honor it. (page->sxml): Pass #:summarize? #t.
parent 2eaeaa99
......@@ -24,8 +24,21 @@
(define %web-site-title
"Guix-HPC — Reproducible software deployment for high-performance computing")
(define* (post->sxml post #:key post-uri)
(define (summarize-post post uri)
(match (post-sxml post)
((('p paragraph ...) _ ...)
`((p ,@paragraph)
(p (a (@ (href ,uri)) "Continue reading…"))))
(body
body)))
(define* (post->sxml post #:key post-uri summarize?)
"Return the SXML for POST."
(define post-body*
(if summarize?
(cut summarize-post <> post-uri)
post-sxml))
`(div (@ (class "post"))
(h1 (@ (class "title"))
,(if post-uri
......@@ -37,14 +50,15 @@
" — " ,(date->string (post-date post) "~B ~e, ~Y"))
(hr)
(div (@ (class "post-body"))
,(syntax-highlight (post-sxml post)))))
,(syntax-highlight (post-body* post)))))
(define (page->sxml site title posts prefix)
"Return the SXML for the news page of SITE, containing POSTS."
`((div (@ (class "header"))
(div (@ (class "post-list"))
,@(map (lambda (post)
(post->sxml post #:post-uri (post-url post site)))
(post->sxml post #:post-uri (post-url post site)
#:summarize? #t))
posts)))))
(define (post->page post site)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment