mirror of
https://git.adityakumar.xyz/hugo-theme-introduction.git
synced 2024-11-09 23:09:47 +00:00
Fix sorted menu (#150)
This commit is contained in:
commit
770fd5c0a6
1 changed files with 44 additions and 35 deletions
|
@ -41,37 +41,41 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ with .Site.GetPage "/home" }}
|
{{ with .Site.GetPage "/home" }}
|
||||||
{{ range sort (.Resources.ByType "page") "Params.weight" }}
|
{{ $pages := .Resources.ByType "page" }}
|
||||||
{{ if ne .Name "contact.md" }}
|
|
||||||
<a class="navbar-item" href="{{ if $isHome }}#{{ .File.TranslationBaseName }}{{ else }}{{ printf "/#%s" (.File.TranslationBaseName | urlize) | relLangURL }}{{ end }}">{{ .Title }}</a>
|
{{ with .Site.GetPage "/blog" }}
|
||||||
{{ end }}
|
{{ $pages = $pages | append . }}
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ $pageIsInProjects := eq .Page.Section "projects"}}
|
|
||||||
{{ if not (and $pageIsInProjects (eq .Page.Kind "section")) }}
|
|
||||||
{{ with .Site.GetPage "/projects" }}
|
{{ with .Site.GetPage "/projects" }}
|
||||||
{{ $totalProjects := (len .Pages) }}
|
{{ $pages = $pages | append . }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ range sort $pages "Params.weight" }}
|
||||||
|
{{ if ne .Name "contact.md" }}
|
||||||
|
{{ if eq .File.Dir "projects/" }}
|
||||||
|
<!-- Now for some cool projects -->
|
||||||
{{ if $isHome }}
|
{{ if $isHome }}
|
||||||
<a class="navbar-item" href="{{ printf "#%s" (.Title | urlize) }}">{{ .Title }}</a>
|
<a class="navbar-item" href="{{ printf "/#%s" ( .Title | urlize) | relLangURL }}">{{ .Title }}</a>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
|
{{ $pageIsInProjects := eq $.Page.Section "project"}}
|
||||||
|
{{ if not (and $pageIsInProjects (eq $.Page.Kind "section")) }}
|
||||||
<a class="navbar-item" href="{{ .Permalink }}">
|
<a class="navbar-item" href="{{ .Permalink }}">
|
||||||
{{ if $pageIsInProjects }}
|
{{ if $pageIsInProjects }}
|
||||||
{{ i18n "nav_backToSection" . }}
|
{{ i18n "nav_backToSection" . }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ .Title }}
|
{{ .Title | singularize}}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</a>
|
</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ else if eq .File.Dir "blog/" }}
|
||||||
|
<!-- Let`s show some blog posts -->
|
||||||
{{ $pageIsInBlog := eq .Page.Section "blog"}}
|
|
||||||
{{ if not (and $pageIsInBlog (eq .Page.Kind "section")) }}
|
|
||||||
{{ with .Site.GetPage "/blog" }}
|
|
||||||
{{ if $isHome }}
|
{{ if $isHome }}
|
||||||
<a class="navbar-item" href="{{ printf "#%s" (.Title | urlize) }}">{{ .Title }}</a>
|
<a class="navbar-item" href="{{ printf "/#%s" ( .Title | urlize) | relLangURL }}">{{ .Title }}</a>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
|
{{ $pageIsInBlog := eq $.Page.Section "blog"}}
|
||||||
|
{{ if not (and $pageIsInBlog (eq $.Page.Kind "section")) }}
|
||||||
<a class="navbar-item" href="{{ .Permalink }}">
|
<a class="navbar-item" href="{{ .Permalink }}">
|
||||||
{{ if $pageIsInBlog }}
|
{{ if $pageIsInBlog }}
|
||||||
{{ i18n "nav_backToSection" . }}
|
{{ i18n "nav_backToSection" . }}
|
||||||
|
@ -81,6 +85,11 @@
|
||||||
</a>
|
</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ else }}
|
||||||
|
<a class="navbar-item" href="{{ if $isHome }}#{{ .File.TranslationBaseName }}{{ else }}{{ printf "/#%s" (.File.TranslationBaseName | urlize) | relLangURL }}{{ end }}">{{ .Title }}</a>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ with .Site.GetPage "/home" }}
|
{{ with .Site.GetPage "/home" }}
|
||||||
|
|
Loading…
Reference in a new issue