Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/thingsym/hugo-theme-techdoc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthingsym <thingsym@gmail.com>2019-11-02 08:32:08 +0300
committerthingsym <thingsym@gmail.com>2019-11-02 08:36:03 +0300
commit4c8d9499342e948c2158073ec806fcce577d16d0 (patch)
tree6a15c5d45352ed6f8adcffeda3e382232cf621e0 /layouts
parentaccc83bd0b0bc2231c20c3db822f1ba58c59fd39 (diff)
feat: add Menu style
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/menu/open-menu.html (renamed from layouts/partials/menu.html)18
-rw-r--r--layouts/partials/menu/slide-menu.html58
-rw-r--r--layouts/partials/sidebar.html6
3 files changed, 72 insertions, 10 deletions
diff --git a/layouts/partials/menu.html b/layouts/partials/menu/open-menu.html
index 0d00ecc..510fc30 100644
--- a/layouts/partials/menu.html
+++ b/layouts/partials/menu/open-menu.html
@@ -1,30 +1,30 @@
{{$currentNode := .}}
-<nav>
+<nav class="open-menu">
<ul>
<li class="{{ if .IsHome }}active{{ end }}"><a href="{{ .Site.BaseURL }}">Home</a></li>
{{- if eq .Site.Params.ordersectionsby "title" -}}
{{- range .Site.Home.Sections.ByTitle -}}
-{{template "menu" dict "sect" . "currentnode" $currentNode}}
+{{template "open-menu" dict "sect" . "currentnode" $currentNode}}
{{- end -}}
{{- else -}}
{{- range .Site.Home.Sections.ByWeight -}}
-{{template "menu" dict "sect" . "currentnode" $currentNode}}
+{{template "open-menu" dict "sect" . "currentnode" $currentNode}}
{{- end -}}
{{- end}}
</ul>
</nav>
-{{define "menu"}}
+{{define "open-menu"}}
{{- $currentNode := .currentnode -}}
{{ with .sect }}
{{ if .IsSection }}
{{ if in .Site.Params.menu_exclusion .Section }}
{{- else -}}
{{- safeHTML .Params.head -}}
-<li class="{{ if .IsAncestor $currentNode }}parent{{ end }}{{ if eq .UniqueID $currentNode.UniqueID }} active{{ end }}{{ if .Params.alwaysopen }} parent{{ end }}"><a href="{{ .URL }}">{{ safeHTML .Params.Pre }}{{ .Title }}{{ safeHTML .Params.Post }}</a>
{{- $numberOfPages := (add (len .Pages) (len .Sections)) -}}
- {{if ne $numberOfPages 0}}
-<ul class="{{ if .IsAncestor $currentNode }}sub-menu{{ end }}">
+<li class="{{ if .IsAncestor $currentNode }}parent{{ end }}{{ if eq .UniqueID $currentNode.UniqueID }} active{{ end }}{{ if .Params.alwaysopen }} parent{{ end }}"><a href="{{ .URL }}">{{ safeHTML .Params.Pre }}{{ .Title }}{{ safeHTML .Params.Post }}</a>
+ {{ if ne $numberOfPages 0 }}
+<ul class="sub-menu">
{{- .Scratch.Set "pages" .Pages -}}
{{- if .Sections -}}
{{- .Scratch.Set "pages" (.Pages | union .Sections) -}}
@@ -34,14 +34,14 @@
{{- range $pages.ByTitle -}}
{{- if and .Params.hidden (not $.showhidden) -}}
{{- else -}}
-{{template "menu" dict "sect" . "currentnode" $currentNode}}
+{{template "open-menu" dict "sect" . "currentnode" $currentNode}}
{{- end -}}
{{- end -}}
{{- else -}}
{{- range $pages.ByWeight -}}
{{- if and .Params.hidden (not $.showhidden) -}}
{{- else -}}
-{{template "menu" dict "sect" . "currentnode" $currentNode}}
+{{template "open-menu" dict "sect" . "currentnode" $currentNode}}
{{- end -}}
{{- end -}}
{{- end}}
diff --git a/layouts/partials/menu/slide-menu.html b/layouts/partials/menu/slide-menu.html
new file mode 100644
index 0000000..bc8e1ea
--- /dev/null
+++ b/layouts/partials/menu/slide-menu.html
@@ -0,0 +1,58 @@
+{{$currentNode := .}}
+<nav class="slide-menu">
+<ul>
+<li class="{{ if .IsHome }}active{{ end }}"><a href="{{ .Site.BaseURL }}">Home</a></li>
+{{- if eq .Site.Params.ordersectionsby "title" -}}
+ {{- range .Site.Home.Sections.ByTitle -}}
+{{template "slide-menu" dict "sect" . "currentnode" $currentNode}}
+ {{- end -}}
+{{- else -}}
+ {{- range .Site.Home.Sections.ByWeight -}}
+{{template "slide-menu" dict "sect" . "currentnode" $currentNode}}
+ {{- end -}}
+{{- end}}
+</ul>
+</nav>
+
+{{define "slide-menu"}}
+{{- $currentNode := .currentnode -}}
+{{ with .sect }}
+{{ if .IsSection }}
+{{ if in .Site.Params.menu_exclusion .Section }}
+{{- else -}}
+ {{- safeHTML .Params.head -}}
+ {{- $numberOfPages := (add (len .Pages) (len .Sections)) -}}
+<li class="{{ if .IsAncestor $currentNode }}parent{{ end }}{{ if eq .UniqueID $currentNode.UniqueID }} active{{ end }}{{ if ne $numberOfPages 0 }} has-sub-menu{{ end }}"><a href="{{ .URL }}">{{ safeHTML .Params.Pre }}{{ .Title }}{{ safeHTML .Params.Post }}{{ if ne $numberOfPages 0 }}{{ if .IsAncestor $currentNode }}<span class="mark opened">-</span>{{ else }}<span class="mark closed">+</span>{{ end }}{{ end }}</a>
+ {{ if ne $numberOfPages 0 }}
+<ul class="sub-menu">
+ {{- .Scratch.Set "pages" .Pages -}}
+ {{- if .Sections -}}
+ {{- .Scratch.Set "pages" (.Pages | union .Sections) -}}
+ {{- end -}}
+ {{- $pages := (.Scratch.Get "pages") -}}
+ {{- if eq .Site.Params.ordersectionsby "title" -}}
+ {{- range $pages.ByTitle -}}
+ {{- if and .Params.hidden (not $.showhidden) -}}
+ {{- else -}}
+{{template "slide-menu" dict "sect" . "currentnode" $currentNode}}
+ {{- end -}}
+ {{- end -}}
+ {{- else -}}
+ {{- range $pages.ByWeight -}}
+ {{- if and .Params.hidden (not $.showhidden) -}}
+ {{- else -}}
+{{template "slide-menu" dict "sect" . "currentnode" $currentNode}}
+ {{- end -}}
+ {{- end -}}
+ {{- end}}
+</ul>
+ {{end}}
+</li>
+{{- end -}}
+{{- else -}}
+ {{- if not .Params.Hidden -}}
+<li class="{{ if eq .UniqueID $currentNode.UniqueID }}active{{ end }}"><a href="{{ .URL }}">{{ safeHTML .Params.Pre }}{{ .Title }}{{ safeHTML .Params.Post }}</a></li>
+ {{- end -}}
+{{ end -}}
+{{ end -}}
+{{ end }}
diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html
index 1ee9b4b..ca9e04c 100644
--- a/layouts/partials/sidebar.html
+++ b/layouts/partials/sidebar.html
@@ -1,5 +1,9 @@
<div class="sidebar">
-{{- partial "menu.html" . -}}
+{{ if eq .Site.Params.menu_style "open-menu" }}
+{{- partial "menu/open-menu.html" . -}}
+{{ else if eq .Site.Params.menu_style "slide-menu" }}
+{{- partial "menu/slide-menu.html" . -}}
+{{ end }}
<div class="sidebar-footer">
{{- partial "sidebar-footer.html" . -}}
</div>