blob: 91f50f895e8b65c6ab91da4edd540e79a8095661 (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
<div class="menu">
<h6 class="menu__label">
{{ if .IsHome }}
{{ .Site.Title }}
{{ else }}
{{ .Type }}
{{ 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) }}down{{ else }}right{{ end }}">
{{ partial "svgs/arrow-right.svg" (dict "width" 22 "height" 22) }}
</span>
</span>
<ul class="menu__list {{ if and (in $currentURL .Permalink) (eq $sectionName1 $sectionName2) }}active{{ end }}">
{{ range .Pages.ByWeight }}
{{ $lastUrlElement := index (last 1 (split (delimit (split .Permalink "/") "," "") ",")) 0 }}
<li>
<a href="{{ .Permalink }}" class="menu__title {{ if and (in $currentURL $lastUrlElement) (eq $sectionName1 $sectionName2) }}active{{ end }}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
{{ else }}
{{ $lastUrlElement := index (last 1 (split (delimit (split .Permalink "/") "," "") ",")) 0 }}
<li class="{{ if in $currentURL $lastUrlElement }}active{{ end }}">
<a href="{{ .Permalink }}" class="menu__title {{ if in $currentURL $lastUrlElement }}active{{ end }}">{{ .Title }}</a>
</li>
{{ end }}
{{ end }}
</ul>
</div>
<script>
var menuTitle = document.querySelectorAll('.menu__title');
var modal = document.getElementById("myModal");
var drawer = document.getElementById('myDrawer');
var closeDrawer = function () {
setTimeout(function () {
modal.style.opacity = 0;
drawer.style.left = '-100%';
modal.style.left = '-100%';
}, 250);
}
menuTitle ?
menuTitle.forEach(function(elem) {
elem.onclick = function() {
closeDrawer();
localStorage.setItem('isDrawerOpen', 'false');
}
}) : null;
</script>
|