diff options
author | Alex Shpak <alex-shpak@users.noreply.github.com> | 2018-09-18 01:35:54 +0200 |
---|---|---|
committer | Alex Shpak <alex-shpak@users.noreply.github.com> | 2018-09-18 01:35:54 +0200 |
commit | 8678e82154226d31ff2833c83fc078d6260a218f (patch) | |
tree | ce36a6825aaea3323980548df9db547a9c7d15f9 /layouts/partials/docs/nav-filetree.html | |
parent | 561659ed53a1eb1e7583513af5fa2faba55fca7e (diff) |
Improve side menu rendering
Diffstat (limited to 'layouts/partials/docs/nav-filetree.html')
-rw-r--r-- | layouts/partials/docs/nav-filetree.html | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/layouts/partials/docs/nav-filetree.html b/layouts/partials/docs/nav-filetree.html index 7c80ae2..6c2f965 100644 --- a/layouts/partials/docs/nav-filetree.html +++ b/layouts/partials/docs/nav-filetree.html @@ -1,51 +1,47 @@ <!-- Put configured sections list to .Scratch --> -{{ template "book-get-root-section" . }} +{{ template "book-get-root-section" . }} -<ul> - {{ range .Scratch.Get "BookSections" }} - {{ template "book-section" (dict "Section" . "CurrentPage" $.Permalink) }} - {{ end }} -</ul> - -<!-- Single section of menu (recursive) --> -{{ define "book-section" }} - <li {{ if .Section.Params.booktopsection }}class="book-nav-section"{{ end }}> +{{- range .Scratch.Get "BookSections" -}} + {{ template "book-section" (dict "Section" . "CurrentPage" $.Permalink) }} +{{- end -}} - {{ with .Section}} +{{ define "book-section" }} <!-- Single section of menu (recursive) --> + <ul> + {{ range .Section.Sections }} + <li> {{- if .Content -}} - <a href="{{ .RelPermalink }}">{{- template "title" . -}}</a> + {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }} {{- else -}} {{- template "title" . -}} {{- end -}} + + {{ template "book-section" (dict "Section" . "CurrentPage" $.CurrentPage) }} + </li> + {{ end }} + + {{ range .Section.Pages }} + <li> + {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }} + </li> {{ end }} + </ul> +{{ end }} - <ul> - {{ range .Section.Sections }} - {{ template "book-section" (dict "Section" . "CurrentPage" $.CurrentPage) }} - {{ end }} - {{ range .Section.Pages }} - <li> - <a href="{{ .RelPermalink }}" class="{{ if eq $.CurrentPage .Permalink }}active{{ end }}"> - {{- template "title" . -}} - </a> - </li> - {{ end }} - </ul> - </li> +{{ define "book-page-link" }} +{{- with .Page -}} +<a href="{{ .RelPermalink }}" {{- if eq $.CurrentPage .Permalink }} class="active"{{ end }}> + {{- template "title" . -}} +</a> +{{- end -}} {{ end }} {{ define "book-get-root-section" }} - <!-- Complex logic to guess page title without .Title specified --> +<!-- Complex logic to guess page title without .Title specified --> {{ $bookSection := default "docs" .Site.Params.BookSection }} {{ if eq $bookSection "*" }} {{ .Scratch.Set "BookSections" .Site.Sections }} {{ else }} {{ $bookSections := where .Site.Sections "Section" $bookSection }} {{ .Scratch.Set "BookSections" $bookSections }} - - {{ if eq (len $bookSections) 1 }} - {{ $singleSection := index $bookSections 0 }} - {{ .Scratch.Set "BookSections" $singleSection.Sections }} - {{ end }} {{ end }} {{ end }}
\ No newline at end of file |