-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.boot
68 lines (62 loc) · 2.46 KB
/
build.boot
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(set-env!
:source-paths #{"src"}
:resource-paths #{"resources"}
:dependencies '[[org.clojure/clojure "1.8.0" :scope "provided"]
[hiccup "1.0.5"]
[perun "0.4.0-20160730.220016-2"]
[clj-time "0.12.0"]
[deraen/boot-less "0.5.0"]
[deraen/boot-livereload "0.1.2"]
[deraen/boot-hyphenate "0.1.0"]
[pandeiro/boot-http "0.7.3"]
[org.slf4j/slf4j-nop "1.7.21"]
[org.webjars.npm/normalize.css "3.0.3"]
[org.webjars.npm/highlight.js "8.7.0"]])
(require '[io.perun :refer :all]
'[pandeiro.boot-http :refer [serve]]
'[deraen.boot-less :refer [less]]
'[deraen.boot-livereload :refer [livereload]]
'[deraen.boot-hyphenate :refer [hyphenate-html]]
'[boot.core :as boot]
'[clojure.string :as string]
'[io.perun.core :as perun])
(deftask split-keywords []
(boot/with-pre-wrap fileset
(->> fileset
(perun/get-meta)
(map (fn [{:keys [keywords] :as post}]
(if (string? keywords)
(assoc post :keywords (->> (string/split keywords #",")
(mapv string/trim)))
post)))
(perun/set-meta fileset))))
(deftask build
[p prod bool "Build rss, sitemap etc."]
(comp (less :source-map (not prod) :compression prod)
(markdown :options {:extensions {:extanchorlinks true}})
(global-metadata)
(if prod (draft) identity)
(slug)
(permalink :permalink-fn #(str (:slug %) "/"))
(canonical-url)
(split-keywords)
(render :renderer 'blog.views.post/render)
(collection :renderer 'blog.views.index/render :page "index.html")
(collection :renderer 'blog.views.tags/render :page "tags/index.html")
(hyphenate-html :remove #{#"^public/tags/index.html$" #"^public/index.html"} :language "en-gb")
(atom-feed
:filterer :original
:filename "atom.xml")
(if prod (sitemap :filename "sitemap.xml") identity)
))
(deftask dev []
(comp (repl :server true)
(watch)
(build)
(livereload :asset-path "public" :filter #"\.(css|html|js)$")
(serve :resource-root "public")))
(deftask prod []
(comp (build :prod true)
(sift :include #{#"^public"})
(sift :move {#"^public/" ""})
(target :dir #{"build"})))