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

single-menu.html « sections « main « partials « layouts - github.com/zzossig/hugo-theme-zdoc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3f6d042566fb8248d36e70bc71fdc79609ec9e08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<div class="menu">
  <h6 class="menu__label">
    {{ if .IsHome }}
      {{ .Site.Title }}
    {{ else }}
      {{ $.Param "Title" }}
    {{ end }}
  </h6>
  <ul>
    {{ $currentURL := .Permalink }}
    {{ range (.Site.GetPage "section" .Type).Pages }}
      {{ $sectionName1 := index (last 1 (split (delimit (split .Permalink "/") "," "") ",")) 0 }}
      {{ $sectionName2 := index (last 2 (split (delimit (split $currentURL "/") "," "") ",")) 0 }}
      {{ if .Params.Collapsible }}
        <span class="menu__title--collapse {{ if and (in $currentURL .Permalink) (eq $sectionName1 $sectionName2) }}active{{ end }}">
          {{ .Title }}
          <span class="menu__title--icon {{ if and (in $currentURL .Permalink) (eq $sectionName1 $sectionName2) }}{{ if eq ($.Param "languagedir") "rtl" }}downrtl{{ else }}down{{ end }}{{ else }}right{{ end }}">
            {{ if eq ($.Param "languagedir") "rtl" }}
              {{ partial "svgs/arrow-left.svg" (dict "width" 22 "height" 22) }}
            {{ else }}
              {{ partial "svgs/arrow-right.svg" (dict "width" 22 "height" 22) }}
            {{ end }}
          </span>
        </span>
        <ul class="menu__list {{ if and (in $currentURL .Permalink) (eq $sectionName1 $sectionName2) }}active{{ end }}">
          {{ range .Pages.ByWeight }}
            {{ $lastUrlElement1 := index (last 1 (split (delimit (split .Permalink "/") "," "") ",")) 0 }}
            {{ $lastUrlElement2 := index (last 1 (split (delimit (split $currentURL "/") "," "") ",")) 0 }}
            <li>
              <a href="{{ .Permalink }}" class="menu__title {{ if and (eq $lastUrlElement1 $lastUrlElement2) (eq $sectionName1 $sectionName2) }}active{{ end }}">{{ .Title }}</a>
            </li>
          {{ end }}
        </ul>
      {{ else }}
        {{ $lastUrlElement1 := index (last 1 (split (delimit (split .Permalink "/") "," "") ",")) 0 }}
        {{ $lastUrlElement2 := index (last 1 (split (delimit (split $currentURL "/") "," "") ",")) 0 }}
        <li>
          <a href="{{ .Permalink }}" class="menu__title {{ if in $lastUrlElement1 $lastUrlElement2 }}active{{ end }}">{{ .Title }}</a>
        </li>
      {{ end }}
    {{ end }}
  </ul>
</div>