blob: 4fc90a9c2ef5b5cfbd43df9c7e179d652d5d7bee (
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
|
(ns core
(:require [clojure.java.io :as io]
[pages :refer [pages]]))
(defn clean []
(let [target-dir (io/file "target")]
(when (.exists target-dir)
(doseq [file (file-seq target-dir)
:when (.isFile file)]
(io/delete-file file))
(doseq [dir (reverse (filter #(.isDirectory %) (file-seq target-dir)))
:when (not= dir target-dir)]
(.delete dir)))))
(defn build []
(doseq [[path page-fn] (pages)]
(let [target-path (if (= path "/")
"target/html/index.html"
(str "target/html" path "/index.html"))
target-file (io/file target-path)]
(io/make-parents target-file)
(spit target-file (str (page-fn))))))
(defn -main []
(clean)
(build))
|