mirror of
https://github.com/trwnh/hugo-theme-paradox.git
synced 2024-11-24 10:21:21 +00:00
use details to only open current section in docs menu
This commit is contained in:
parent
89c0a4dca9
commit
317e9651c9
|
@ -9,19 +9,23 @@
|
||||||
<a id="menu" href="#top">Skip menu</a>
|
<a id="menu" href="#top">Skip menu</a>
|
||||||
{{ $currentPage := . }}
|
{{ $currentPage := . }}
|
||||||
{{ range .Site.Menus.docs }}
|
{{ range .Site.Menus.docs }}
|
||||||
{{ if .HasChildren}}
|
{{ $active := or ($currentPage.IsMenuCurrent "docs" .) (eq $currentPage.Section .Identifier)}}
|
||||||
<li
|
{{ if .HasChildren }}
|
||||||
class='section-title{{ if or ($currentPage.IsMenuCurrent "docs" .) (eq $currentPage.Section .Identifier) }} active{{ end }}'>
|
<details
|
||||||
<a href="{{ .URL | relLangURL }}">
|
class='section-title
|
||||||
|
{{- if $active }} active{{ end -}}
|
||||||
|
'
|
||||||
|
{{- if $active }} open{{ end -}}>
|
||||||
|
<summary href="{{ .URL | relLangURL }}">
|
||||||
{{ .Pre }}
|
{{ .Pre }}
|
||||||
<span>{{ .Name }}</span>
|
<span>{{ .Name }}</span>
|
||||||
{{ .Post }}
|
{{ .Post }}
|
||||||
</a>
|
</summary>
|
||||||
<ul class="sub-menu">
|
<ul class="sub-menu">
|
||||||
{{ range .Children }}
|
{{ range .Children }}
|
||||||
{{ if .HasChildren}}
|
{{ if .HasChildren}}
|
||||||
<li
|
<li
|
||||||
class='{{ if or ($currentPage.IsMenuCurrent "docs" .) (eq $currentPage.Section .Identifier) }} active{{ end }}'>
|
class='{{- if $active }} active{{ end -}}'>
|
||||||
<a href="{{ .URL | relLangURL }}">
|
<a href="{{ .URL | relLangURL }}">
|
||||||
{{ .Pre }}
|
{{ .Pre }}
|
||||||
<span>{{ .Name }}</span>
|
<span>{{ .Name }}</span>
|
||||||
|
@ -30,7 +34,7 @@
|
||||||
<ul class="sub-menu">
|
<ul class="sub-menu">
|
||||||
{{ range .Children }}
|
{{ range .Children }}
|
||||||
<li
|
<li
|
||||||
class='{{ if or ($currentPage.IsMenuCurrent "docs" .) (eq $currentPage.Section .Identifier) }}active{{ end }}'>
|
class='{{- if $active }} active{{ end -}}'>
|
||||||
<a href="{{ .URL | relLangURL }}">
|
<a href="{{ .URL | relLangURL }}">
|
||||||
{{ .Pre }}
|
{{ .Pre }}
|
||||||
<span>{{ .Name }}</span>
|
<span>{{ .Name }}</span>
|
||||||
|
@ -39,10 +43,10 @@
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</details>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<li
|
<li
|
||||||
class='{{ if or ($currentPage.IsMenuCurrent "docs" .) (eq $currentPage.Section .Identifier) }}active{{ end }}'>
|
class='{{- if $active }} active{{ end -}}'>
|
||||||
<a href="{{ .URL | relLangURL }}">
|
<a href="{{ .URL | relLangURL }}">
|
||||||
{{ .Pre }}
|
{{ .Pre }}
|
||||||
<span>{{ .Name }}</span>
|
<span>{{ .Name }}</span>
|
||||||
|
@ -55,7 +59,7 @@
|
||||||
</li>
|
</li>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<li
|
<li
|
||||||
class='{{ if or ($currentPage.IsMenuCurrent "docs" .) (eq $currentPage.Section .Identifier) }}active{{ end }}'>
|
class='{{- if $active }} active{{ end -}}'>
|
||||||
<a href="{{ .URL | relLangURL }}">
|
<a href="{{ .URL | relLangURL }}">
|
||||||
{{ .Pre }}
|
{{ .Pre }}
|
||||||
<span>{{ .Name }}</span>
|
<span>{{ .Name }}</span>
|
||||||
|
|
Loading…
Reference in a new issue