blob: 1c9728ca9a8868ee87be7d7bf719ce3dfa489bcf (
about) (
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
|
(use-modules ((gnu packages haskell-xyz) #:select (pandoc))
((gnu packages python) #:select (python))
(guix build utils)
(guix gexp))
(define (build-post post)
(computed-file (basename post ".md")
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils))
(let ((posts-directory (string-append #$output "/posts/")))
(mkdir-p posts-directory)
(invoke #$(file-append pandoc "/bin/pandoc")
"--from" "markdown"
"--to" "html"
"--standalone"
"--output" (string-append posts-directory
#$(basename post ".md")
".html")
#$(local-file post)))))))
(define (build-index posts)
(computed-file "blog-index"
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils))
(invoke #$(file-append python "/bin/python3")
#$(local-file "generate-index.py")
"index.md"
#$@(map (lambda (file)
(local-file file))
posts))
(mkdir #$output)
(invoke #$(file-append pandoc "/bin/pandoc")
"--from" "markdown"
"--to" "html"
"--standalone"
"--metadata" "title=My blog"
"--output" (string-append #$output "/index.html")
"index.md")))))
(let ((posts (find-files "posts" "\\.md$")))
(directory-union "blog"
(cons (build-index posts)
(map build-post posts))))
|