Flesh out page structure
This commit is contained in:
parent
0bae8c01f8
commit
85e79a8090
5 changed files with 105 additions and 25 deletions
47
index.janet
47
index.janet
|
|
@ -14,13 +14,44 @@
|
|||
|
||||
(bagatto/set-output-dir! "site")
|
||||
|
||||
(def data {:config {:attrs {:title "arnes.space"}}
|
||||
:posts {:src (bagatto/slurp-* "posts/*.md")
|
||||
:attrs bagatto/parse-mmarkdown}})
|
||||
(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/base data [:h1 "Hello World!"])}
|
||||
:posts {:each :posts
|
||||
:dest (bagatto/%p "posts" '%i "title" '% ".html")
|
||||
:out (fn [data item]
|
||||
(views/base data (bagatto/mmarkdown->html (item :contents)) true))}})
|
||||
: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)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue