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

Use pretty URLs for blog posts.

* guix-hpc.scm (post-url): Add the year and month to the post URL.
* haunt.scm (post->page): New procedure.
<top-level>: Use custom procedures instead of 'blog'.
* nginx-locations.conf: Add redirect for 'guix-hpc-debut.html'.
parent 3679d577
......@@ -4,12 +4,14 @@
;;; Copyright © 2017 Inria
(define-module (guix-hpc)
#:use-module (haunt post)
#:use-module (haunt page)
#:use-module (haunt site)
#:use-module (haunt html)
#:use-module (haunt reader)
#:use-module (haunt reader commonmark)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-19)
#:export (base-url
image-url
css-url
......@@ -30,7 +32,15 @@
(define (post-url post site)
"Return the URL of POST, a Haunt blog post, for SITE."
(base-url "/blog/" (site-post-slug site post) ".html"))
(let ((date (post-date post)))
(base-url "/blog/"
(number->string (date-year date))
"/"
(string-pad (number->string (date-month date))
2 #\0)
;; There's an implicit "/index.html" here.
"/" (site-post-slug site post))))
(define* (base-layout body #:key (title "Guix-HPC"))
......
......@@ -19,6 +19,7 @@
(ice-9 match)
(srfi srfi-1)
(srfi srfi-19)
(srfi srfi-26)
(guix-hpc))
(define %web-site-title
......@@ -47,6 +48,11 @@
(post->sxml post #:post-uri (post-url post site)))
posts)))))
(define (post->page post site)
(make-page (string-append (post-url post site) "/index.html")
(render-post %hpc-haunt-theme site post)
sxml->html))
(define %hpc-haunt-theme
;; Theme for the rendering of the news pages.
(theme #:name "Guix-HPC"
......@@ -72,8 +78,18 @@
(email . "guix-devel@gnu.org"))
#:readers (list commonmark-reader)
#:builders
(cons* (blog #:theme %hpc-haunt-theme
#:prefix "blog")
(cons* (lambda (site posts)
;; Pages for each post.
(map (cut post->page <> site) posts))
(lambda (site posts)
;; The main collection.
(make-page
"/blog/index.html"
(render-collection %hpc-haunt-theme site
%web-site-title
posts "/blog")
sxml->html))
;; Apparently the <link> tags of Atom entries must be absolute URLs,
;; hence this #:blog-prefix.
......
......@@ -9,7 +9,7 @@ location /.well-known {
# Redirects for old URLs.
location = /guix-hpc-debut.html {
return 301 /blog/guix-hpc-debut.html;
return 301 /blog/2017/09/guix-hpc-debut;
}
location = /feed.xml {
return 301 /blog/feed.xml;
......
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