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

github.com/ojroques/hugo-researcher.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Roques <olivier@oroques.dev>2020-11-25 13:31:11 +0300
committerOlivier Roques <olivier@oroques.dev>2020-11-25 13:31:11 +0300
commit049680a6dc2402d44fae0a1a7d601b301d2c272b (patch)
tree31ce8ef21e69a1b1950fb1627b59851a6d269e34
parente2c5b8073f97bc5848afbb303785adb4af079457 (diff)
Add support for menu item pre and post hooks
Closes #8
-rw-r--r--exampleSite/config.toml3
-rw-r--r--layouts/partials/header.html4
2 files changed, 6 insertions, 1 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index a78b5d6..7dd0f4a 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -25,6 +25,9 @@ googleAnalytics = "" # add your tracking id
[[menu.main]]
name = "Resume"
url = "/resume.pdf"
+ # 'pre' and 'post' hooks are available
+ # here we use an icon from Bootstrap https://icons.getbootstrap.com/
+ pre = '<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-file-earmark-person-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M2 2a2 2 0 0 1 2-2h5.293A1 1 0 0 1 10 .293L13.707 4a1 1 0 0 1 .293.707V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2zm7.5 1.5v-2l3 3h-2a1 1 0 0 1-1-1zM11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0zm2 5.755S12 12 8 12s-5 1.755-5 1.755V14a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-.245z"/></svg> '
weight = 2
[[menu.main]]
name = "Contact"
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index 7fcd975..aba1999 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -5,7 +5,9 @@
{{ with .Site.Menus.main }}
{{ $navbar_len := len . }}
{{ range $i, $nav_item := . }}
- <a class="nav-item nav-link" href="{{ $nav_item.URL }}">{{ $nav_item.Name }}</a>
+ <a class="nav-item nav-link" href="{{ $nav_item.URL }}">
+ {{ $nav_item.Pre }}{{ $nav_item.Name }}{{ $nav_item.Post }}
+ </a>
{{ if ne (add $i 1) $navbar_len }}
<span class="nav-item navbar-text mx-1">/</span>
{{ end }}