Implement template-map

Return a map of templates based on their filenames as keywords.

Could be better, as I understand right now it's not recursive.
This commit is contained in:
Archie Hilton 2024-10-15 00:01:03 +01:00
parent b68614edca
commit ba95015e26
1 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,17 @@
(ns website.core (ns website.core
:require [clojure.java.io :as io]) (:require [clojure.java.io :as io]))
(def template-dir "./site/templates")
;; Thank you https://clojure.org/api/cheatsheet
(def template-map
"Grab all files in the template directory and insert them into a map with
the filenames as keyword keys"
(let [files (filter #(.isFile %) (file-seq (io/file template-dir)))
] (mapcat #(assoc {} (keyword (.getName %)) (slurp %)) files)))
(defn foo (defn foo
"I don't do a whole lot." "I don't do a whole lot."