render blog sites

master
Josha von Gizycki 6 years ago
parent f59cf5641b
commit 2ed52864c5

@ -0,0 +1,5 @@
---
{:title "first entry"}
---
# JAHOOO

@ -39,10 +39,20 @@
(blog-target-root {:blog-dir-name "hudel"}) (blog-target-root {:blog-dir-name "hudel"})
(blog-sites-dir "datblag")) (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 (let [index-file (io/file (str (target-root config
output-root) output-root)
"/index.html"))] "/index.html"))]
(io/make-parents index-file) (io/make-parents index-file)
(spit 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))))

@ -133,6 +133,7 @@
(defn analysed-page [file] (defn analysed-page [file]
(let [content (slurp file)] (let [content (slurp file)]
{:file file {:file file
:filename (filename file)
:content (-> content page-content render-markdown) :content (-> content page-content render-markdown)
:metadata (page-metadata content)})) :metadata (page-metadata content)}))
@ -160,7 +161,9 @@
config (merge (blog/config dir-name config (merge (blog/config dir-name
(analysed-page index-file)) (analysed-page index-file))
{:dir dir}) {: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 (blog/write-files config
output-root output-root
blog-sites blog-sites

Loading…
Cancel
Save