aboutsummaryrefslogtreecommitdiff
path: root/layouts/partials/docs/menu-filetree.html
diff options
context:
space:
mode:
authorAlex Shpak <alex-shpak@users.noreply.github.com>2018-09-26 00:12:56 +0200
committerAlex Shpak <alex-shpak@users.noreply.github.com>2018-09-26 00:12:56 +0200
commitcce17bcc99be389dce5bfbadfabaacf132c3f8f7 (patch)
tree71cfa0cc6451ab321f0884fc4e7ef0ad189259cc /layouts/partials/docs/menu-filetree.html
parentb6d7a1050fe273869646242304899f0a0f1483b2 (diff)
Remove purecss dependency and replace with flexbox
Diffstat (limited to 'layouts/partials/docs/menu-filetree.html')
-rw-r--r--layouts/partials/docs/menu-filetree.html47
1 files changed, 47 insertions, 0 deletions
diff --git a/layouts/partials/docs/menu-filetree.html b/layouts/partials/docs/menu-filetree.html
new file mode 100644
index 0000000..490c350
--- /dev/null
+++ b/layouts/partials/docs/menu-filetree.html
@@ -0,0 +1,47 @@
+<!-- Put configured sections list to .Scratch -->
+{{ template "book-get-root-section" . }}
+
+{{- range .Scratch.Get "BookSections" -}}
+ {{ template "book-section" (dict "Section" . "CurrentPage" $.Permalink) }}
+{{- end -}}
+
+{{ define "book-section" }} <!-- Single section of menu (recursive) -->
+ <ul>
+ {{ range .Section.Sections }}
+ <li {{- if .Params.bookrootsection}} class="section" {{ end }}>
+ {{- if .Content -}}
+ {{ 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 }}
+
+{{ 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 -->
+ {{ $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 }}
+ {{ end }}
+{{ end }} \ No newline at end of file