Update the navbar to highlight depend on the page.
This commit is contained in:
@@ -37,3 +37,14 @@
|
|||||||
"..."
|
"..."
|
||||||
""))))
|
""))))
|
||||||
|
|
||||||
|
(defn navbar-item-style-factory
|
||||||
|
[]
|
||||||
|
(clj->js
|
||||||
|
(fn [url prefix]
|
||||||
|
(let [baseurl (-> (or url "")
|
||||||
|
(.split "?")
|
||||||
|
(first))]
|
||||||
|
(if (= baseurl prefix)
|
||||||
|
"block py-2 px-3 text-white bg-blue-700 rounded md:bg-transparent md:text-blue-700 md:p-0 dark:text-white md:dark:text-blue-500"
|
||||||
|
"block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent")))))
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,11 @@
|
|||||||
|
|
||||||
(.registerHelper (.-handlebars hbs)
|
(.registerHelper (.-handlebars hbs)
|
||||||
"is-brief"
|
"is-brief"
|
||||||
(helpers/is-brief-factory))))
|
(helpers/is-brief-factory))
|
||||||
|
|
||||||
|
(.registerHelper (.-handlebars hbs)
|
||||||
|
"navbar-item-style"
|
||||||
|
(helpers/navbar-item-style-factory))))
|
||||||
|
|
||||||
(defn setup-engine
|
(defn setup-engine
|
||||||
"Sets the engine to handlebars and simple set up."
|
"Sets the engine to handlebars and simple set up."
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<nav class="bg-gray-50 border-gray-200 dark:bg-gray-900">
|
<nav class="bg-gray-50 border-gray-200 dark:bg-gray-900">
|
||||||
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
|
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
|
||||||
<a href="https://flowbite.com/" class="flex items-center space-x-3 rtl:space-x-reverse">
|
<a href="/" class="flex items-center space-x-3 rtl:space-x-reverse">
|
||||||
<span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">Blog</span>
|
<span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">Blog</span>
|
||||||
</a>
|
</a>
|
||||||
<button data-collapse-toggle="navbar-default" type="button" class="inline-flex items-center p-2 w-10 h-10 justify-center text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600" aria-controls="navbar-default" aria-expanded="false">
|
<button data-collapse-toggle="navbar-default" type="button" class="inline-flex items-center p-2 w-10 h-10 justify-center text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600" aria-controls="navbar-default" aria-expanded="false">
|
||||||
@@ -12,10 +12,10 @@
|
|||||||
<div class="hidden w-full md:block md:w-auto" id="navbar-default">
|
<div class="hidden w-full md:block md:w-auto" id="navbar-default">
|
||||||
<ul class="font-medium flex flex-col p-4 md:p-0 mt-4 border border-gray-100 rounded-lg bg-gray-50 md:flex-row md:space-x-8 rtl:space-x-reverse md:mt-0 md:border-0 md:bg-white dark:bg-gray-800 md:dark:bg-gray-900 dark:border-gray-700">
|
<ul class="font-medium flex flex-col p-4 md:p-0 mt-4 border border-gray-100 rounded-lg bg-gray-50 md:flex-row md:space-x-8 rtl:space-x-reverse md:mt-0 md:border-0 md:bg-white dark:bg-gray-800 md:dark:bg-gray-900 dark:border-gray-700">
|
||||||
<li>
|
<li>
|
||||||
<a href="/" class="block py-2 px-3 text-white bg-blue-700 rounded md:bg-transparent md:text-blue-700 md:p-0 dark:text-white md:dark:text-blue-500" aria-current="page">Home</a>
|
<a href="/" class="{{ navbar-item-style url '/'}}" aria-current="page">Home</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/about" class="block py-2 px-3 text-gray-900 rounded hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent">About</a>
|
<a href="/about" class="{{ navbar-item-style url '/about'}}">About</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user