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

133 lines
4.8 KiB
HTML
Raw Normal View History

2018-06-11 23:39:40 +00:00
<!-- Begin Nav bar -->
<div class="container">
2018-06-27 08:58:30 +00:00
<hr>
2018-07-10 07:23:19 +00:00
<nav class="navbar" role="navigation" aria-label="main navigation">
2018-06-27 08:58:30 +00:00
{{ $isHome := .Page.IsHome }}
2018-07-10 07:23:19 +00:00
<a role="button" class="navbar-burger" data-target="navMenu" aria-label="menu" aria-expanded="false" >
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
<div class="navbar-menu" id="navMenu">
2018-07-01 16:09:14 +00:00
<!-- look for custom menu and include it -->
{{ if .Site.Menus.main }}
{{ range .Site.Menus.main }}
{{ if .HasChildren }}
2018-07-10 07:23:19 +00:00
<a class="navbar-item" href="{{ .URL }}">
2018-07-01 16:09:14 +00:00
{{ .Pre }}
{{ .Name }}
{{ .Post }}
</a>
{{ range .Children }}
<!-- TODO: style children diffrent then parents-->
2018-07-10 07:23:19 +00:00
<a class="navbar-item" href="{{ .URL }}">
2018-07-01 16:09:14 +00:00
{{ .Pre }}
{{ .Name }}
{{ .Post }}
</a>
{{ end }}
{{ else }}
2018-07-10 07:23:19 +00:00
<a class="navbar-item" href="{{ .URL }}">
2018-07-01 16:09:14 +00:00
{{ .Pre }}
{{ .Name }}
{{ .Post }}
</a>
{{ end }}
{{ end }}
{{ else }}
<!-- use default menu -->
2018-06-27 08:58:30 +00:00
{{ if not $isHome }}
2018-07-10 07:23:19 +00:00
<a class="navbar-item" href="{{ "/" | relLangURL }}">{{ i18n "nav_main" . }}</a>
2018-06-27 08:58:30 +00:00
{{ end }}
2018-07-18 15:47:54 +00:00
{{ with .Site.GetPage "page" "home" }}
{{ range sort (.Resources.ByType "page") "Params.weight" }}
{{ if ne .Name "contact.md" }}
2018-07-10 07:23:19 +00:00
<a class="navbar-item" href="{{ if $isHome }}#{{ .File.TranslationBaseName }}{{ else }}{{ printf "/#%s" .File.TranslationBaseName | relLangURL }}{{ end }}">{{ .Title }}</a>
2018-06-27 08:58:30 +00:00
{{ end }}
2018-07-18 15:47:54 +00:00
{{ end }}
{{ end }}
2018-06-11 23:39:40 +00:00
2018-06-27 08:58:30 +00:00
{{ $pageIsInProjects := eq .Page.Section "projects"}}
{{ if not (and $pageIsInProjects (eq .Page.Kind "section")) }}
{{ with .Site.GetPage "section" "projects" }}
{{ if $isHome }}
2018-07-10 07:23:19 +00:00
<a class="navbar-item" href="#{{ .Title | urlize }}">{{ .Title }}</a>
2018-06-27 08:58:30 +00:00
{{ else }}
2018-07-10 07:23:19 +00:00
<a class="navbar-item" href="{{ .RelPermalink }}">
2018-06-27 08:58:30 +00:00
{{ if $pageIsInProjects }}
{{ i18n "nav_backToSection" . }}
{{ else }}
{{ .Title }}
{{ end }}
</a>
{{ end }}
{{ end }}
{{ end }}
2018-06-11 23:39:40 +00:00
2018-06-27 08:58:30 +00:00
{{ $pageIsInBlog := eq .Page.Section "blog"}}
{{ if not (and $pageIsInBlog (eq .Page.Kind "section")) }}
{{ with .Site.GetPage "section" "blog" }}
{{ if $isHome }}
2018-07-10 07:23:19 +00:00
<a class="navbar-item" href="#{{ .Title | urlize }}">{{ .Title }}</a>
2018-06-27 08:58:30 +00:00
{{ else }}
2018-07-10 07:23:19 +00:00
<a class="navbar-item" href="{{ .RelPermalink }}">
2018-06-27 08:58:30 +00:00
{{ if $pageIsInBlog }}
Back to {{ .Title | singularize}}
{{ else }}
{{ .Title | singularize}}
{{ end }}
</a>
{{ end }}
{{ end }}
{{ end }}
2018-06-11 23:39:40 +00:00
2018-07-18 15:47:54 +00:00
{{ with .Site.GetPage "page" "home" }}
{{ with .Resources.GetMatch "contact.md" }}
2018-07-10 07:23:19 +00:00
<a class="navbar-item" href="{{ if $isHome }}#{{ .File.TranslationBaseName }}{{ else }}{{ printf "/#%s" .File.TranslationBaseName | relLangURL }}{{ end }}">{{ .Title }}</a>
2018-06-27 08:58:30 +00:00
{{ end }}
2018-07-18 15:47:54 +00:00
{{ end }}
2018-06-27 00:10:46 +00:00
{{ if gt (len $.Site.Home.AllTranslations.ByWeight) 1 }}
2018-06-27 08:58:30 +00:00
{{ range $.Site.Home.AllTranslations.ByWeight }}
2018-07-10 07:23:19 +00:00
<a class="navbar-item" href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
{{ end }}
2018-06-27 08:58:30 +00:00
{{ end }}
2018-06-11 23:39:40 +00:00
2018-06-27 08:58:30 +00:00
{{ if and .Site.Params.showRSSButton .Site.RSSLink }}
2018-07-12 10:15:25 +00:00
<a class="navbar-item" href="{{ .Site.RSSLink }}"><i class="fas fa-rss"></i></a>
2018-06-27 08:58:30 +00:00
{{ end }}
2018-07-01 16:09:14 +00:00
{{ end }}
2018-06-27 08:58:30 +00:00
</div>
</nav>
<hr>
2018-06-11 23:39:40 +00:00
</div>
2018-07-10 07:23:19 +00:00
<script>
document.addEventListener('DOMContentLoaded', function () {
// Get all "navbar-burger" elements
var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
// Check if there are any navbar burgers
if ($navbarBurgers.length > 0) {
// Add a click event on each of them
$navbarBurgers.forEach(function ($el) {
$el.addEventListener('click', function () {
// Get the target from the "data-target" attribute
var target = $el.dataset.target;
var $target = document.getElementById(target);
// Toggle the class on both the "navbar-burger" and the "navbar-menu"
$el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
}
});
</script>
2018-06-11 23:39:40 +00:00
<!-- End Nav bar -->