parent
cd451f56ac
commit
f59cf5641b
@ -0,0 +1,48 @@
|
|||||||
|
(ns equilibrium.blog
|
||||||
|
(:require [clojure.java.io :as io]
|
||||||
|
[clojure.string :as string]))
|
||||||
|
|
||||||
|
(defn index-file [dir-name root]
|
||||||
|
(io/file (str root "/blogs/" dir-name "/index.md")))
|
||||||
|
|
||||||
|
(defn sites-dir [dir-name root]
|
||||||
|
(str root "/blogs/" dir-name "/entries"))
|
||||||
|
|
||||||
|
(defn analysed-blog-dir-name [dir-name]
|
||||||
|
(let [name-parts (string/split dir-name #"\+")]
|
||||||
|
(case (count name-parts)
|
||||||
|
1 ["" (first name-parts)]
|
||||||
|
2 [(first name-parts) (second name-parts)])))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(analysed-blog-dir-name "hudel")
|
||||||
|
(analysed-blog-dir-name "4711+wudel"))
|
||||||
|
|
||||||
|
(defn config [dir-name analysed-index]
|
||||||
|
(let [[ix blog-dir-name] (analysed-blog-dir-name dir-name)]
|
||||||
|
(merge {:ix ix
|
||||||
|
:blog-dir-name blog-dir-name}
|
||||||
|
(update-in analysed-index
|
||||||
|
[:metadata :page-size]
|
||||||
|
#(or % 10)))))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(blog-index-file "datblag")
|
||||||
|
(blog-config "datblag"))
|
||||||
|
|
||||||
|
(defn target-root [config root]
|
||||||
|
(str root
|
||||||
|
"/"
|
||||||
|
(:blog-dir-name config)))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(blog-target-root {:blog-dir-name "hudel"})
|
||||||
|
(blog-sites-dir "datblag"))
|
||||||
|
|
||||||
|
(defn write-files [config output-root site-files 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))))
|
Loading…
Reference in new issue