(import janet-html :as html)
(import path)
(defn as-html [h]
(html/encode (html/doctype :html5) [:html h]))
(bagatto/set-output-dir! "site")
(def data {:config {:attrs {:title "arnes.space"}}
:posts {:src (bagatto/slurp-* "posts/*.md")
:attrs bagatto/parse-mmarkdown}})
(defn header [data]
[:head
[:meta {:charset "utf-8"}]
[:title (get-in data [:config :title])]])
(def site {:index {:dest "index.html"
:out (fn [data]
(as-html [(header data) [:body [:h1 "Hello World"]]]))}
:posts {:each :posts
:dest (bagatto/%p "posts" '%i "title" '% ".html")
:out (fn [data item]
(as-html [(header data) [:body (html/raw (bagatto/mmarkdown->html (item :contents)))]]))}})