added debug switch & improved home vs. preview handling

This commit is contained in:
Michael Jerger 2016-12-31 11:20:09 +01:00
parent 0e882e6637
commit e796a5adc5

View file

@ -225,13 +225,14 @@
(defn compile-pages (defn compile-pages
"Compiles all the pages into html and spits them out into the public folder" "Compiles all the pages into html and spits them out into the public folder"
[{:keys [blog-prefix page-root-uri] :as params} pages] [{:keys [blog-prefix page-root-uri debug?] :as params} pages]
(when-not (empty? pages) (when-not (empty? pages)
(println (blue "compiling pages")) (println (blue "compiling pages"))
(create-folder (path "/" blog-prefix page-root-uri)) (create-folder (path "/" blog-prefix page-root-uri))
(doseq [{:keys [uri] :as page} pages] (doseq [{:keys [uri] :as page} pages]
(println "\t-->" (cyan uri)) (println "\t-->" (cyan uri))
(println "\t-->" (cyan page)) (when debug?
(println "\t-->" (cyan page)))
(write-html uri (write-html uri
params params
(render-file (str "/html/" (:layout page)) (render-file (str "/html/" (:layout page))
@ -354,6 +355,7 @@
[{:keys [disqus?] :as params}] [{:keys [disqus?] :as params}]
(println (blue "compiling index")) (println (blue "compiling index"))
(let [uri (page-uri "index.html" params) (let [uri (page-uri "index.html" params)
debug? (-> params :debug?)
home-page (-> params :home-page) home-page (-> params :home-page)
meta {:active-page "home" meta {:active-page "home"
:home true :home true
@ -361,8 +363,8 @@
:uri uri :uri uri
:post home-page :post home-page
:page home-page}] :page home-page}]
(println "\t-->" (cyan meta)) (when debug?
(println "\t-->" (cyan (first (-> params :latest-posts)))) (println "\t-->" (cyan meta)))
(write-html uri (write-html uri
params params
(render-file (str "/html/" (:layout home-page)) (render-file (str "/html/" (:layout home-page))
@ -460,7 +462,7 @@
"Generates all the html and copies over resources specified in the config" "Generates all the html and copies over resources specified in the config"
[] []
(println (green "compiling assets...")) (println (green "compiling assets..."))
(let [{:keys [^String site-url blog-prefix rss-name recent-posts sass-src sass-dest sass-path compass-path keep-files ignored-files previews? author-root-uri] :as config} (read-config) (let [{:keys [^String site-url blog-prefix rss-name recent-posts sass-src sass-dest sass-path compass-path keep-files ignored-files previews? clean-urls? debug? author-root-uri] :as config} (read-config)
posts (add-prev-next (read-posts config)) posts (add-prev-next (read-posts config))
pages (add-prev-next (read-pages config)) pages (add-prev-next (read-pages config))
home-pages (filter #(boolean (:home? %)) pages) home-pages (filter #(boolean (:home? %)) pages)
@ -499,8 +501,9 @@
(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)
(if previews? (when previews?
(compile-preview-pages params posts) (compile-preview-pages params posts))
(when (or (not-empty home-pages) (not previews?))
(compile-index params)) (compile-index params))
(compile-archives params posts) (compile-archives params posts)
(when author-root-uri (when author-root-uri