Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zwbetz-gh/vanilla-bootstrap-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachary Betz <zwbetz@gmail.com>2019-01-02 20:23:23 +0300
committerZachary Betz <zwbetz@gmail.com>2019-01-02 20:23:23 +0300
commitff399df36dff4e5fe278a754e2070ad60370ecfd (patch)
tree15ffb4011188ecc997c39a5355513c18e0872a50
parente4b127d32c975160df785ddf2a044b04f8ac3119 (diff)
Config option for active nav
-rw-r--r--exampleSite/config.toml1
-rw-r--r--exampleSite/config.yaml1
-rw-r--r--layouts/partials/nav.html11
3 files changed, 9 insertions, 4 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 7850380..0048b92 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -45,6 +45,7 @@ googleAnalytics = "UA-123456789-1"
[params]
includeBootstrapJs = false
+ showActiveNav = true
containerMaxWidth = "700px"
dateFormat = "Jan 2, 2006"
homeText = "Welcome to the Vanilla theme demo. Have a look around. Maybe even eat some ice cream."
diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml
index d38698a..d189103 100644
--- a/exampleSite/config.yaml
+++ b/exampleSite/config.yaml
@@ -41,6 +41,7 @@ menu:
params:
includeBootstrapJs: false
+ showActiveNav: true
containerMaxWidth: 700px
dateFormat: Jan 2, 2006
homeText: Welcome to the Vanilla theme demo. Have a look around. Maybe even eat some ice cream.
diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html
index c869177..e797f62 100644
--- a/layouts/partials/nav.html
+++ b/layouts/partials/nav.html
@@ -1,12 +1,15 @@
<div id="nav-border" class="container">
<nav id="nav" class="nav justify-content-center">
+ {{ $showActiveNav := .Site.Params.showActiveNav }}
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
{{ $active := "" }}
- {{ $menu := or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }}
- {{ if or $menu (eq $currentPage.Title .Name) }}
- {{ $active = "nav-link-active" }}
- {{ end }}
+ {{ if eq $showActiveNav true }}
+ {{ $isMenu := or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }}
+ {{ if or $isMenu (eq $currentPage.Title .Name) }}
+ {{ $active = "nav-link-active" }}
+ {{ end }}
+ {{ end }}
<a class="nav-link {{ $active }}" href="{{ .URL }}">{{ print .Pre " " .Name | safeHTML }}</a>
{{ end }}
</nav>