hugo-theme-introduction/layouts/partials/nav.html

98 lines
3.7 KiB
HTML

<!-- Begin Nav bar -->
<div class="container">
<hr>
<nav class="nav nav-center">
{{ $isHome := .Page.IsHome }}
<span id="nav-toggle" class="nav-toggle" onclick="document.getElementById('nav-menu').classList.toggle('is-active');">
<span></span>
<span></span>
<span></span>
</span>
<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 }}
<a class="nav-item" href="{{ "/" | relLangURL }}">{{ i18n "nav_main" . }}</a>
{{ end }}
{{ with .Site.GetPage "page" "about" }}
<a class="nav-item" href="{{ if $isHome }}#{{ .File.TranslationBaseName }}{{ else }}{{ printf "/#%s" .File.TranslationBaseName | relLangURL }}{{ end }}">{{ .Title }}</a>
{{ end }}
{{ $pageIsInProjects := eq .Page.Section "projects"}}
{{ if not (and $pageIsInProjects (eq .Page.Kind "section")) }}
{{ with .Site.GetPage "section" "projects" }}
{{ if $isHome }}
<a class="nav-item" href="#{{ .Title | urlize }}">{{ .Title }}</a>
{{ else }}
<a class="nav-item" href="{{ .RelPermalink }}">
{{ if $pageIsInProjects }}
{{ i18n "nav_backToSection" . }}
{{ else }}
{{ .Title }}
{{ end }}
</a>
{{ end }}
{{ end }}
{{ end }}
{{ $pageIsInBlog := eq .Page.Section "blog"}}
{{ if not (and $pageIsInBlog (eq .Page.Kind "section")) }}
{{ with .Site.GetPage "section" "blog" }}
{{ if $isHome }}
<a class="nav-item" href="#{{ .Title | urlize }}">{{ .Title }}</a>
{{ else }}
<a class="nav-item" href="{{ .RelPermalink }}">
{{ if $pageIsInBlog }}
Back to {{ .Title | singularize}}
{{ else }}
{{ .Title | singularize}}
{{ end }}
</a>
{{ end }}
{{ end }}
{{ end }}
{{ with .Site.GetPage "page" "contact" }}
<a class="nav-item" href="{{ if $isHome }}#{{ .File.TranslationBaseName }}{{ else }}{{ printf "/#%s" .File.TranslationBaseName | relLangURL }}{{ end }}">{{ .Title }}</a>
{{ end }}
{{ if gt (len $.Site.Home.AllTranslations.ByWeight) 1 }}
{{ range $.Site.Home.AllTranslations.ByWeight }}
<a class="nav-item" href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
{{ end }}
{{ end }}
{{ if and .Site.Params.showRSSButton .Site.RSSLink }}
<a class="nav-item" href="{{ .Site.RSSLink }}"><i class="fa fa-rss"></i></a>
{{ end }}
{{ end }}
</div>
</nav>
<hr>
</div>
<!-- End Nav bar -->