compile hierarchic pages
This commit is contained in:
parent
6cf7b1a72b
commit
e8d7069598
2 changed files with 23 additions and 22 deletions
|
@ -251,7 +251,9 @@
|
||||||
:home false
|
:home false
|
||||||
:servlet-context (cryogen-io/path "/" blog-prefix "/")
|
:servlet-context (cryogen-io/path "/" blog-prefix "/")
|
||||||
:page page
|
:page page
|
||||||
:uri uri}))))))
|
:uri uri})))
|
||||||
|
(compile-pages params (:children page)))
|
||||||
|
))
|
||||||
|
|
||||||
(defn compile-posts
|
(defn compile-posts
|
||||||
"Compiles all the posts into html and spits them out into the public folder"
|
"Compiles all the posts into html and spits them out into the public folder"
|
||||||
|
@ -490,28 +492,29 @@
|
||||||
(println (green "compiling assets..."))
|
(println (green "compiling assets..."))
|
||||||
(let [{:keys [^String site-url blog-prefix rss-name recent-posts sass-dest keep-files ignored-files previews?
|
(let [{:keys [^String site-url blog-prefix rss-name recent-posts sass-dest keep-files ignored-files previews?
|
||||||
author-root-uri theme debug? page-model]
|
author-root-uri theme debug? page-model]
|
||||||
:as config} (read-config)
|
:as config} (read-config)
|
||||||
posts (map klipsify (add-prev-next (read-posts config)))
|
posts (map klipsify (add-prev-next (read-posts config)))
|
||||||
posts-by-tag (group-by-tags posts)
|
posts-by-tag (group-by-tags posts)
|
||||||
posts (tag-posts posts config)
|
posts (tag-posts posts config)
|
||||||
latest-posts (->> posts (take recent-posts) vec)
|
latest-posts (->> posts (take recent-posts) vec)
|
||||||
pages (map klipsify (read-pages config))
|
klipsified-pages (map klipsify (read-pages config))
|
||||||
home-page (->> pages
|
modelled-pages (cond
|
||||||
(filter #(boolean (:home? %)))
|
(= page-model :flat) klipsified-pages
|
||||||
(first))
|
(= page-model :hierarchic) (hierarchic/build-hierarchic-map klipsified-pages)
|
||||||
other-pages (->> pages
|
)
|
||||||
(remove #{home-page})
|
home-page (->> modelled-pages
|
||||||
(add-prev-next))
|
(filter #(boolean (:home? %)))
|
||||||
|
(first))
|
||||||
|
other-pages (->> modelled-pages
|
||||||
|
(remove #{home-page})
|
||||||
|
(add-prev-next))
|
||||||
params (merge config
|
params (merge config
|
||||||
{:today (java.util.Date.)
|
{:today (java.util.Date.)
|
||||||
:title (:site-title config)
|
:title (:site-title config)
|
||||||
:active-page "home"
|
:active-page "home"
|
||||||
:tags (map (partial tag-info config) (keys posts-by-tag))
|
:tags (map (partial tag-info config) (keys posts-by-tag))
|
||||||
:latest-posts latest-posts
|
:latest-posts latest-posts
|
||||||
:pages (cond
|
:pages other-pages
|
||||||
(= page-model :flat) other-pages
|
|
||||||
(= page-model :hierarchic) (hierarchic/build-hierarchic-map other-pages)
|
|
||||||
)
|
|
||||||
:home-page (if home-page
|
:home-page (if home-page
|
||||||
home-page
|
home-page
|
||||||
(assoc (first latest-posts) :layout "home.html"))
|
(assoc (first latest-posts) :layout "home.html"))
|
||||||
|
@ -523,8 +526,6 @@
|
||||||
(when debug?
|
(when debug?
|
||||||
(println (blue "debug: page-model:"))
|
(println (blue "debug: page-model:"))
|
||||||
(println "\t-->" (cyan page-model))
|
(println "\t-->" (cyan page-model))
|
||||||
(println (blue "debug: pages:"))
|
|
||||||
(println "\t-->" (cyan (-> params :pages)))
|
|
||||||
(println (blue "debug: home-page:"))
|
(println (blue "debug: home-page:"))
|
||||||
(println "\t-->" (cyan (-> params :home-page)))
|
(println "\t-->" (cyan (-> params :home-page)))
|
||||||
)
|
)
|
||||||
|
@ -535,7 +536,7 @@
|
||||||
(println (blue "copying resources"))
|
(println (blue "copying resources"))
|
||||||
(cryogen-io/copy-resources config)
|
(cryogen-io/copy-resources config)
|
||||||
(copy-resources-from-markup-folders config)
|
(copy-resources-from-markup-folders config)
|
||||||
(compile-pages params other-pages)
|
(compile-pages params modelled-pages)
|
||||||
(compile-posts params posts)
|
(compile-posts params posts)
|
||||||
(compile-tags params posts-by-tag)
|
(compile-tags params posts-by-tag)
|
||||||
(compile-tags-page params)
|
(compile-tags-page params)
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
(defn build-hierarchic-level
|
(defn build-hierarchic-level
|
||||||
"builds one level of nav-map and recurs to next level."
|
"builds one level of hierarchic tree recurs to next level."
|
||||||
[parent-uri pages]
|
[parent-uri pages]
|
||||||
(let [current-level (+ 1 (uri-level parent-uri))
|
(let [current-level (+ 1 (uri-level parent-uri))
|
||||||
pages-of-parent (filter-pages-for-uri parent-uri pages)
|
pages-of-parent (filter-pages-for-uri parent-uri pages)
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
))
|
))
|
||||||
|
|
||||||
(defn build-hierarchic-map
|
(defn build-hierarchic-map
|
||||||
"builds a nav-map from pages"
|
"builds a hierarchic tree from pages"
|
||||||
[pages]
|
[pages]
|
||||||
(let [sorted-pages (sort-by :uri pages)]
|
(let [sorted-pages (sort-by :uri pages)]
|
||||||
(build-hierarchic-level "/pages/" sorted-pages)
|
(build-hierarchic-level "/pages/" sorted-pages)
|
||||||
|
|
Loading…
Reference in a new issue