Add active-page key to config map
For certain pages a key with a boolean value is added to the config map which can then be used in templates to determine if it is the page being rendered. Not all pages have this key and boolean value. Instead of adding additional keys for every page a new generic key, 'active-page', has been added and its value is the page name, ex: 'home', 'archives', 'tags', etc. The default value is 'home'. This key can then be used in any template to check the page which is currently being rendered.
This commit is contained in:
parent
42faca4b82
commit
8eb0e9ff29
1 changed files with 20 additions and 12 deletions
|
@ -198,7 +198,8 @@
|
|||
(spit (str public uri)
|
||||
(render-file (str "/html/" (:layout page))
|
||||
(merge params
|
||||
{:servlet-context "../"
|
||||
{:active-page "pages"
|
||||
:servlet-context "../"
|
||||
:page page
|
||||
:uri uri}))))))
|
||||
|
||||
|
@ -213,7 +214,8 @@
|
|||
(spit (str public (:uri post))
|
||||
(render-file (str "/html/" (:layout post))
|
||||
(merge params
|
||||
{:servlet-context "../"
|
||||
{:active-page "posts"
|
||||
:servlet-context "../"
|
||||
:post post
|
||||
:disqus-shortname disqus-shortname
|
||||
:uri (:uri post)}))))))
|
||||
|
@ -230,7 +232,8 @@
|
|||
(spit (str public uri)
|
||||
(render-file "/html/tag.html"
|
||||
(merge params
|
||||
{:servlet-context "../"
|
||||
{:active-page "tags"
|
||||
:servlet-context "../"
|
||||
:name name
|
||||
:posts posts
|
||||
:uri uri})))))))
|
||||
|
@ -240,7 +243,8 @@
|
|||
(spit (str public blog-prefix "/tags.html")
|
||||
(render-file "/html/tags.html"
|
||||
(merge params
|
||||
{:uri (str blog-prefix "/tags.html")}))))
|
||||
{:active-page "tags"
|
||||
:uri (str blog-prefix "/tags.html")}))))
|
||||
|
||||
(defn create-preview
|
||||
"Creates a single post preview"
|
||||
|
@ -282,7 +286,8 @@
|
|||
(spit (if (= 1 index) (str public blog-prefix "/index.html") (str public blog-prefix "/p/" index))
|
||||
(render-file "/html/previews.html"
|
||||
(merge params
|
||||
{:servlet-context (if (= 1 index) "" "../")
|
||||
{:active-page "preview"
|
||||
:servlet-context (if (= 1 index) "" "../")
|
||||
:posts posts
|
||||
:prev-uri prev
|
||||
:next-uri next})))))))
|
||||
|
@ -294,7 +299,8 @@
|
|||
(spit (str public blog-prefix "/index.html")
|
||||
(render-file "/html/home.html"
|
||||
(merge params
|
||||
{:home true
|
||||
{:active-page "home"
|
||||
:home true
|
||||
:disqus? disqus?
|
||||
:post (get-in params [:latest-posts 0])
|
||||
:uri (str blog-prefix "/index.html")}))))
|
||||
|
@ -306,7 +312,8 @@
|
|||
(spit (str public blog-prefix "/archives.html")
|
||||
(render-file "/html/archives.html"
|
||||
(merge params
|
||||
{:archives true
|
||||
{:active-page "archives"
|
||||
:archives true
|
||||
:groups (group-for-archive posts)
|
||||
:uri (str blog-prefix "/archives.html")}))))
|
||||
|
||||
|
@ -360,6 +367,7 @@
|
|||
posts (tag-posts posts config)
|
||||
params (merge config
|
||||
{:title (:site-title config)
|
||||
:active-page "home"
|
||||
:tags (map (partial tag-info config) (keys posts-by-tag))
|
||||
:latest-posts (->> posts (take recent-posts) vec)
|
||||
:navbar-pages navbar-pages
|
||||
|
|
Loading…
Reference in a new issue