From 175dae050b53725eb8e1e7dac7de220d69f7a772 Mon Sep 17 00:00:00 2001 From: Archie Hilton Date: Mon, 4 Nov 2024 22:14:29 +0000 Subject: [PATCH] Refactor generate-output-file-map to use ->> --- src/website/core.clj | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/website/core.clj b/src/website/core.clj index 45869db..fe69e15 100644 --- a/src/website/core.clj +++ b/src/website/core.clj @@ -20,7 +20,6 @@ the filenames as keyword keys" (let [files (list-files template-dir)] (reduce #(assoc %1 (keyword (.getName %2)) (slurp %2)) {} files))) -; Generate a string-string map of the new filepaths and the unprocessed contents (defn generate-output-file-map "Take the input html files, read them, and create a mapping of their paths to their contents. @@ -28,9 +27,11 @@ the filenames as keyword keys" [html-dir, output-dir] (let [file-listing (list-files html-dir) contents (map slurp file-listing) - old-paths (map #(.getPath %) file-listing) - rootless-paths (map #(subs % (count html-dir)) old-paths) - new-paths (map #(string/join [output-dir %]) rootless-paths)] + new-paths (map #(->> % + .getPath + (drop (count html-dir)) + (cons output-dir) + (string/join)) file-listing)] (zipmap new-paths contents))) (defn put_file @@ -60,5 +61,5 @@ the filenames as keyword keys" (for [of output-file-map] ; of is a key-value pair (put_file (insert_templates of template-map)) - ;(put_file of) + ;(put_file of) )