(import janet-html :as html)
(import spork/netrepl)
(import ./views)
(import ./utils)
# disable pretty-printing
(setdyn :pretty-format "%.20q")
# ---
# site config
# ---
(bagatto/set-output-dir! "site")
(defn struct->table [s]
(table ;(interleave (keys s) (values s))))
(defn path->date [path]
(let [datestr (->>
(string/split "/" path)
(last)
(string/split "--")
(first))
date (struct->table (bagatto/datestr->date datestr true))]
# we have to massage the struct a bit because by default the date is
# interpreted as a local date and converted to UTC.
# NOTE: we don't fix year-day because we'd have to check for leap years.
(put date :hours 0)
(update date :month-day inc)
(update date :week-day (comp |(mod $0 7) inc))))
(defn parse-post [slurped item]
(let [post (bagatto/parse-mmarkdown slurped item) ]
(put post :published-at (path->date (post :path)))
post))
(def data {:config {:attrs {:title "arnes.space"
:stylesheet "assets/style.css"}}
:assets {:src (bagatto/* "assets/*")
:attrs bagatto/parse-base}
:posts {:src (bagatto/slurp-* "content/posts/*.md")
:attrs parse-post}})
(def site {:index {:dest "index.html"
:out views/home}
:assets {:each :assets
:dest (bagatto/path-copier "assets/")}
:posts {:each :posts
:dest utils/slugify-content
:out views/post}})
(comment
(->>
(eval-data data)
(eval-site site)))