From 2ed52864c5b92828cb5f82f85ffb6d4e1fbc5f5a Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Thu, 15 Nov 2018 17:23:12 +0100 Subject: [PATCH] render blog sites --- resources/page/blogs/datblag/entries/01-entry.md | 5 +++++ src/equilibrium/blog.clj | 14 ++++++++++++-- src/equilibrium/render.clj | 5 ++++- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 resources/page/blogs/datblag/entries/01-entry.md diff --git a/resources/page/blogs/datblag/entries/01-entry.md b/resources/page/blogs/datblag/entries/01-entry.md new file mode 100644 index 0000000..6607df3 --- /dev/null +++ b/resources/page/blogs/datblag/entries/01-entry.md @@ -0,0 +1,5 @@ +--- +{:title "first entry"} +--- + +# JAHOOO diff --git a/src/equilibrium/blog.clj b/src/equilibrium/blog.clj index 10bfd82..665ae23 100644 --- a/src/equilibrium/blog.clj +++ b/src/equilibrium/blog.clj @@ -39,10 +39,20 @@ (blog-target-root {:blog-dir-name "hudel"}) (blog-sites-dir "datblag")) -(defn write-files [config output-root site-files fill-in-fn] +(defn site->target-file [config root site] + (io/file (str (target-root config root) + "/" + (:filename site) + ".html"))) + +(defn write-files [config output-root sites fill-in-fn] (let [index-file (io/file (str (target-root config output-root) "/index.html"))] (io/make-parents index-file) (spit index-file - (fill-in-fn config)))) + (fill-in-fn config))) + (doseq [site sites + :let [target (site->target-file config output-root site)]] + (spit target + (fill-in-fn site)))) diff --git a/src/equilibrium/render.clj b/src/equilibrium/render.clj index dd9689a..f010da6 100644 --- a/src/equilibrium/render.clj +++ b/src/equilibrium/render.clj @@ -133,6 +133,7 @@ (defn analysed-page [file] (let [content (slurp file)] {:file file + :filename (filename file) :content (-> content page-content render-markdown) :metadata (page-metadata content)})) @@ -160,7 +161,9 @@ config (merge (blog/config dir-name (analysed-page index-file)) {:dir dir}) - blog-sites (md-files (blog/sites-dir dir-name input-root))] + blog-sites (->> (blog/sites-dir dir-name input-root) + md-files + (map analysed-page))] (blog/write-files config output-root blog-sites