Allow different layouts for different pages
This commit is contained in:
parent
78e2506d34
commit
d2c7ec794b
3 changed files with 83 additions and 38 deletions
31
views.janet
31
views.janet
|
|
@ -86,15 +86,15 @@
|
|||
You can call this with some content and have it generate an entire HTML
|
||||
structure for you.
|
||||
```
|
||||
[data nav body &opt raw?]
|
||||
[page data nav body &opt raw?]
|
||||
(default raw? false)
|
||||
(as-html [(html-head data)
|
||||
[:body
|
||||
[:main
|
||||
[:aside
|
||||
(ten-print body)
|
||||
[:main {:class page}
|
||||
[:header (ten-print body)]
|
||||
[:nav
|
||||
[:h1 (get-in data [:config :title])]
|
||||
[:nav nav]]
|
||||
nav]
|
||||
[:article (if raw? (html/raw body) body)]]]]))
|
||||
|
||||
#
|
||||
|
|
@ -105,23 +105,26 @@
|
|||
(string/format "%j" jdn))
|
||||
|
||||
(defn home [data]
|
||||
(base data
|
||||
[]
|
||||
[[:h1 "Projects"]
|
||||
(base "home"
|
||||
data
|
||||
[[:h2 "Projects"]
|
||||
[:ul
|
||||
[:li "Berliner Winter"]
|
||||
[:li "Vanilla Sky"]
|
||||
[:li "All My Friends"]
|
||||
[:li "Kosmopolit"]]
|
||||
[:h1 "Recent Posts"]
|
||||
[:h2 "Recent Posts"]
|
||||
[:ul
|
||||
(map (fn [post]
|
||||
[:li [:a {:href (utils/slugify-content data post)} (post "title")]]) (data :posts))]]))
|
||||
[:li [:a {:href (utils/slugify-content data post)} (post "title")]]) (data :posts))]]
|
||||
[]))
|
||||
|
||||
(defn post [data item]
|
||||
(base data
|
||||
(base "post"
|
||||
data
|
||||
[:ul
|
||||
[:li [:a {:href "#"}] "Projects"]
|
||||
[:li [:a {:href "#"}] "Posts"]
|
||||
[:li [:a {:href "#"}] "About"]]
|
||||
[:li [:a {:href (get-in data [:config :base-url])} "Home"]]
|
||||
[:li [:a {:href "#"} "Projects"]]
|
||||
[:li [:a {:href "#"} "Posts"]]
|
||||
[:li [:a {:href "#"} "About"]]]
|
||||
(bagatto/mmarkdown->html (item :contents)) true))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue