summaryrefslogtreecommitdiff
path: root/theme.scm
blob: 4843ed6494c939797496bf1adb7addde6725f45e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
(define-module (theme)
  #:use-module (haunt html)
  #:use-module (haunt site)
  #:use-module (haunt post)
  #:use-module (haunt builder blog)
  #:export (hwebs-theme
            flat-page-template))


(define hwebs-theme
  (theme #:name "hwebs"
         #:layout
         (lambda (site title body)
           `((doctype "html")
             (html
              (head
               (meta (@ (http-equiv "Content-Type")
                        (content "text/html")
                        (charset "utf-8")))
               (meta (@ (name "viewport")
                        (content "width=device-width, initial-scale=1.0")))
               (link (@ (rel "stylesheet")
                        (type "text/css")
                        (href "/style.css")))
               (title ,(string-append title " — " (site-title site))))
              (body
               (header (span ,(assq-ref (site-default-metadata site) 'author))
                       (nav (ul (li (a (@ (href "/")) "Home"))
                                (li (a (@ (href "/blog")) "Blog")))))
               (main
                (article (h1 ,title)
                         ,body))))))
         #:post-template
         (lambda (post)
           ;; TODO fill in datetime correctly
           ;; TODO add <author>? (as hidden?)
           `((time ,(date->string*(post-date post)))
             ,(post-sxml post)))
         #:collection-template
         (lambda (site title posts prefix)
           (define (post-uri post)
             (string-append "/" (or prefix "") "/"
                            (site-post-slug site post) ".html"))
           `((ul
              ,@(map (lambda (post)
                       `(li (a (@ (href ,(post-uri post)))
                               ,(post-ref post 'title)
                               " — "
                               ,(date->string* (post-date post)))))
                     posts))))))

(define (flat-page-template site metadata body)
  ((theme-layout hwebs-theme) site (assq-ref metadata 'title) body))