summaryrefslogtreecommitdiff
path: root/haunt.scm
blob: b3244ced3c7a8bfc8625227761414c966af40470 (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
(use-modules (srfi srfi-1)
             (srfi srfi-19)
             (haunt asset)
             (haunt builder blog)
             (haunt builder atom)
             (haunt builder assets)
             (haunt site)
             (haunt post)
             (src reader)
             (src theme))

;; Set the timezone to UTC, otherwise the dates can get confused.
(setenv "TZ" "utc")

(define (filter-posts-remove-future-drafts posts)
  (filter (lambda (post)
            (time<? (date->time-utc
                     (post-ref post 'start-date))
                    (current-time)))
          posts))

(define (filter-posts-remove-drafts posts)
  (filter (lambda (post)
            (time<? (date->time-utc
                     (post-ref post 'end-date))
                    (current-time)))
          posts))

(site #:title "Guix Weekly News"
      #:domain "prototype-guix-weekly-news.cbaines.net"
      #:build-directory (or (getenv "HAUNT_BUILD_DIRECTORY") "site")
      #:readers (list post-reader)
      #:builders
      (list
       (blog #:theme weekly-news-theme
             #:collections
             `(("Recent posts" "index.html"
                ,(compose (lambda (posts)
                            (if (< (length posts) 8)
                                posts
                                (take posts 8)))
                          filter-posts-remove-future-drafts
                          posts/reverse-chronological))
               ("All posts" "all.html"
                ,(compose filter-posts-remove-drafts
                          posts/reverse-chronological))))
       (atom-feed #:filter
                  (compose filter-posts-remove-drafts
                           posts/reverse-chronological))
       (static-directory "static")))