summaryrefslogtreecommitdiff
path: root/src/core.clj
diff options
context:
space:
mode:
authorJake Zerrer <him@jakezerrer.com>2025-08-12 09:59:18 -0400
committerJake Zerrer <him@jakezerrer.com>2025-08-12 09:59:18 -0400
commit037ac81efc08ad8cbd358930224cd8dc1f1faad8 (patch)
tree54b39f4696dbacc73aeaef785f93bfdc248f3cc3 /src/core.clj
parent9853e1abec320b7018dd2b976280cddfb52ba153 (diff)
First pass
Diffstat (limited to 'src/core.clj')
-rw-r--r--src/core.clj62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/core.clj b/src/core.clj
new file mode 100644
index 0000000..f13531e
--- /dev/null
+++ b/src/core.clj
@@ -0,0 +1,62 @@
+(ns core
+ (:require [borkdude.html :refer [html]]
+ [clojure.java.io :as io]
+ [clojure.string :as str]))
+
+(defn template [body]
+ (html [:html [:head] [:body [:<> body]]]))
+
+(defn home []
+ (template
+ (html
+ [:h1 "home"])))
+
+(defn about []
+ (template
+ (html
+ [:h1 "about"])))
+
+(defn this-life
+ "blog post about this life"
+ []
+ (template
+ (html
+ [:h1 "This life"])))
+
+(defn something-else
+ "blog post about something else"
+ []
+ (template
+ (html
+ [:h1 "Something else"])))
+
+(something-else)
+
+(def pages
+ {"/" home
+ "/about2" about
+ "/blog/this-life" this-life
+ "/blog/something-else" something-else})
+
+(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 compile []
+ (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)
+ (compile))