hugo-theme-introduction/layouts/partials/nav.html
Kevin Ottens 563cf77fe1 Restore home navbar (#90)
* Center the navbar again on the home page

* Favor the project page for listing projects

The project listing has its own page we can link to instead of going
back to the (potentially fading in) home page each time.
2018-10-29 18:44:11 +01:00

106 lines
4.1 KiB
HTML

<!-- Begin Nav bar -->
<div class="container">
<hr>
<nav class="navbar" role="navigation" aria-label="main navigation">
{{ $isHome := .Page.IsHome }}
<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 {{ if $isHome }}has-content-centered{{ end }}" id="navMenu">
<!-- look for custom menu and include it -->
{{ if .Site.Menus.main }}
{{ range .Site.Menus.main }}
{{ if .HasChildren }}
<a class="navbar-item" href="{{ .URL }}">
{{ .Pre }}
{{ .Name }}
{{ .Post }}
</a>
{{ range .Children }}
<!-- TODO: style children diffrent then parents-->
<a class="navbar-item" href="{{ .URL }}">
{{ .Pre }}
{{ .Name }}
{{ .Post }}
</a>
{{ end }}
{{ else }}
<a class="navbar-item" href="{{ .URL }}">
{{ .Pre }}
{{ .Name }}
{{ .Post }}
</a>
{{ end }}
{{ end }}
{{ else }}
<!-- use default menu -->
{{ if not $isHome }}
<a class="navbar-item" href="{{ "/" | absLangURL }}">{{ i18n "nav_main" . }}</a>
{{ end }}
{{ with .Site.GetPage "/home" }}
{{ range sort (.Resources.ByType "page") "Params.weight" }}
{{ if ne .Name "contact.md" }}
<a class="navbar-item" href="{{ if $isHome }}#{{ .File.TranslationBaseName }}{{ else }}{{ printf "/#%s" (.File.TranslationBaseName | urlize) | relLangURL }}{{ end }}">{{ .Title }}</a>
{{ end }}
{{ end }}
{{ end }}
{{ $pageIsInProjects := eq .Page.Section "projects"}}
{{ if not (and $pageIsInProjects (eq .Page.Kind "section")) }}
{{ with .Site.GetPage "/projects" }}
{{ $totalProjects := (len .Pages) }}
{{ if $isHome }}
<a class="navbar-item" href="{{ printf "#%s" (.Title | urlize) }}">{{ .Title }}</a>
{{ else }}
<a class="navbar-item" href="{{ .Permalink }}">
{{ 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 "/blog" }}
{{ if $isHome }}
<a class="navbar-item" href="{{ printf "#%s" (.Title | urlize) }}">{{ .Title }}</a>
{{ else }}
<a class="navbar-item" href="{{ .Permalink }}">
{{ if $pageIsInBlog }}
Back to {{ .Title | singularize}}
{{ else }}
{{ .Title | singularize}}
{{ end }}
</a>
{{ end }}
{{ end }}
{{ end }}
{{ with .Site.GetPage "/home" }}
{{ with .Resources.GetMatch "contact.md" }}
<a class="navbar-item" href="{{ if $isHome }}#{{ .File.TranslationBaseName }}{{ else }}{{ printf "/#%s" (.File.TranslationBaseName | urlize) | relLangURL }}{{ end }}">{{ .Title }}</a>
{{ end }}
{{ end }}
{{ range $.Site.Home.AllTranslations.ByWeight }}
{{ if ne .Language.LanguageName $.Language.LanguageName }}
<a class="navbar-item" href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
{{ end }}
{{ end }}
{{ if and .Site.Params.showRSSButton .Site.RSSLink }}
<a class="navbar-item" href="{{ .Site.RSSLink }}"><i class="fas fa-rss"></i></a>
{{ end }}
{{ end }}
</div>
</nav>
<hr>
</div>
<!-- End Nav bar -->