summaryrefslogtreecommitdiff
path: root/home/src/core.clj
diff options
context:
space:
mode:
Diffstat (limited to 'home/src/core.clj')
-rw-r--r--home/src/core.clj27
1 files changed, 27 insertions, 0 deletions
diff --git a/home/src/core.clj b/home/src/core.clj
new file mode 100644
index 0000000..b8ba344
--- /dev/null
+++ b/home/src/core.clj
@@ -0,0 +1,27 @@
+(ns core
+ (:require [clojure.java.io :as io]
+ [pages :refer [pages e-404]]))
+
+(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)))))
+ (spit (io/file "404.html") (str (e-404))))
+
+(defn -main []
+ (clean)
+ (build))