Allow custom menus

This commit is contained in:
Hanzei 2018-07-01 18:09:14 +02:00
parent c99e22b05a
commit d582fa6592
No known key found for this signature in database
GPG key ID: 69A2DEFD98937BA0
2 changed files with 38 additions and 0 deletions

View file

@ -42,6 +42,16 @@ theme = "introduction"
url = "https://linkedin.com/" url = "https://linkedin.com/"
icon = "linkedin" icon = "linkedin"
# If you don`t want to use the default menu, you can define one by yoursel
# [[menu.main]]
# name = "Home"
# url = "/"
# weight = 0
# [[menu.main]]
# name = "Blog"
# url = "/blog"
# weight = 1
[languages] [languages]
[languages.en] [languages.en]
languageName = "English" languageName = "English"

View file

@ -9,6 +9,33 @@
<span></span> <span></span>
</span> </span>
<div id="nav-menu" class="nav-left nav-menu"> <div id="nav-menu" class="nav-left nav-menu">
<!-- look for custom menu and include it -->
{{ if .Site.Menus.main }}
{{ range .Site.Menus.main }}
{{ if .HasChildren }}
<a class="nav-item" href="{{ .URL }}">
{{ .Pre }}
{{ .Name }}
{{ .Post }}
</a>
{{ range .Children }}
<!-- TODO: style children diffrent then parents-->
<a class="nav-item" href="{{ .URL }}">
{{ .Pre }}
{{ .Name }}
{{ .Post }}
</a>
{{ end }}
{{ else }}
<a class="nav-item" href="{{ .URL }}">
{{ .Pre }}
{{ .Name }}
{{ .Post }}
</a>
{{ end }}
{{ end }}
{{ else }}
<!-- use default menu -->
{{ if not $isHome }} {{ if not $isHome }}
<a class="nav-item" href="{{ "/" | relLangURL }}">{{ i18n "nav_main" . }}</a> <a class="nav-item" href="{{ "/" | relLangURL }}">{{ i18n "nav_main" . }}</a>
{{ end }} {{ end }}
@ -61,6 +88,7 @@
{{ if and .Site.Params.showRSSButton .Site.RSSLink }} {{ if and .Site.Params.showRSSButton .Site.RSSLink }}
<a class="nav-item" href="{{ .Site.RSSLink }}"><i class="fa fa-rss"></i></a> <a class="nav-item" href="{{ .Site.RSSLink }}"><i class="fa fa-rss"></i></a>
{{ end }} {{ end }}
{{ end }}
</div> </div>
</nav> </nav>
<hr> <hr>