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>2018-12-29 21:44:32 +0300
committerZachary Betz <zwbetz@gmail.com>2018-12-29 21:44:32 +0300
commitc1faca8ec03d0334e64d10c5acbdeedbbd1488f9 (patch)
tree4cebf5ca08d7264f81f0fceb3113ddcebd6801cf
parent317c4504293aa3e35df9ceb39e2876b3a1035637 (diff)
Move icon to pre. Set active menu item
-rw-r--r--exampleSite/config.toml15
-rw-r--r--exampleSite/config.yaml15
-rw-r--r--layouts/partials/nav.html7
-rw-r--r--layouts/partials/style.html6
4 files changed, 31 insertions, 12 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 4f6fb45..7850380 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -18,23 +18,28 @@ googleAnalytics = "UA-123456789-1"
[menu]
[[menu.main]]
- name = """<i data-feather="home"></i> Home"""
+ name = "Home"
+ pre = """<i data-feather="home"></i>"""
url = "/"
weight = 1
[[menu.main]]
- name = """<i data-feather="edit"></i> Blog"""
+ name = "Blog"
+ pre = """<i data-feather="edit"></i>"""
url = "/post/"
weight = 2
[[menu.main]]
- name = """<i data-feather="tag"></i> Tags"""
+ name = "Tags"
+ pre = """<i data-feather="tag"></i>"""
url = "/tags/"
weight = 3
[[menu.main]]
- name = """<i data-feather="smile"></i> About"""
+ name = "About"
+ pre = """<i data-feather="smile"></i>"""
url = "/about/"
weight = 4
[[menu.main]]
- name = """<i data-feather="rss"></i> RSS"""
+ name = "RSS"
+ pre = """<i data-feather="rss"></i>"""
url = "/index.xml"
weight = 5
diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml
index 8c31894..d38698a 100644
--- a/exampleSite/config.yaml
+++ b/exampleSite/config.yaml
@@ -18,19 +18,24 @@ permalinks:
menu:
main:
- - name: <i data-feather="home"></i> Home
+ - name: Home
+ pre: <i data-feather="home"></i>
url: /
weight: 1
- - name: <i data-feather="edit"></i> Blog
+ - name: Blog
+ pre: <i data-feather="edit"></i>
url: /post/
weight: 2
- - name: <i data-feather="tag"></i> Tags
+ - name: Tags
+ pre: <i data-feather="tag"></i>
url: /tags/
weight: 3
- - name: <i data-feather="smile"></i> About
+ - name: About
+ pre: <i data-feather="smile"></i>
url: /about/
weight: 4
- - name: <i data-feather="rss"></i> RSS
+ - name: RSS
+ pre: <i data-feather="rss"></i>
url: /index.xml
weight: 5
diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html
index a50e719..e65a033 100644
--- a/layouts/partials/nav.html
+++ b/layouts/partials/nav.html
@@ -1,5 +1,10 @@
<nav id="nav" class="nav justify-content-center">
+{{ $currentPage := . }}
{{ range .Site.Menus.main }}
- <a class="nav-link" href="{{ .URL }}">{{ .Name | safeHTML }}</a>
+ {{ $active := "" }}
+ {{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }}
+ {{ $active = "nav-link-active" }}
+ {{ end }}
+ <a class="nav-link {{ $active }}" href="{{ .URL }}">{{ print .Pre " " .Name | safeHTML }}</a>
{{ end }}
</nav> \ No newline at end of file
diff --git a/layouts/partials/style.html b/layouts/partials/style.html
index 2403a92..ebd409e 100644
--- a/layouts/partials/style.html
+++ b/layouts/partials/style.html
@@ -4,11 +4,15 @@
}
#nav {
border-bottom: 1px solid #212529;
- font-weight: bold;
}
#nav a {
+ font-weight: bold;
color: inherit;
}
+#nav a.nav-link-active {
+ background-color: #212529;
+ color: #fff;
+}
#main {
margin-top: 1rem;
margin-bottom: 3rem;