From ba95015e26de4388a6263e1ffac9e25e1b2108c8 Mon Sep 17 00:00:00 2001 From: Archie Hilton Date: Tue, 15 Oct 2024 00:01:03 +0100 Subject: [PATCH] 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. --- src/website/core.clj | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/website/core.clj b/src/website/core.clj index 200c963..ad9dd16 100644 --- a/src/website/core.clj +++ b/src/website/core.clj @@ -1,5 +1,17 @@ (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 "I don't do a whole lot."