|
| 1 | +{{/* (C) 2023 GoodData Corporation */}} |
| 2 | +<button type="button" id="gd-docs-menu__mobile-trigger" class="gd-docs-menu__mobile-btn" aria-expanded="false" aria-controls="gd-docs-menu" aria-label="Toggle navigation menu"> |
| 3 | + <span class="gd-docs-menu__mobile-icon" aria-hidden="true"></span> |
| 4 | +</button> |
| 5 | +<div class="gd-docs-menu__mobile-bg"></div> |
| 6 | +<nav id="gd-docs-menu" class="gd-docs-menu init" aria-label="Articles"> |
| 7 | + {{ if .Site.Params.versions }} |
| 8 | + {{ partial "navbar-version-selector.html" . }} |
| 9 | + {{ end }} |
| 10 | + |
| 11 | + {{ partial "sidebar-tree.html" . }} |
| 12 | +</nav> |
| 13 | + |
| 14 | +{{ define "root-link" }} |
| 15 | + {{ $isCurrent := eq .currentPage .root.FirstSection }} |
| 16 | + {{ $active := .active }} |
| 17 | + {{ with .root }} |
| 18 | + <ul class="gd-docs-menu-section gd-docs-menu-section__root"> |
| 19 | + <li class="gd-docs-menu-page{{ if or $isCurrent $active }} active{{ end }}"> |
| 20 | + <div class="gd-docs-menu-page__title"> |
| 21 | + <a href="{{ .RelPermalink }}" class="gd-docs-menu-page__link">{{ .LinkTitle }}</a> |
| 22 | + </div> |
| 23 | + </li> |
| 24 | + </ul> |
| 25 | + {{ end }} |
| 26 | +{{ end }} |
| 27 | + |
| 28 | +{{ define "section-tree-nav-sections" }} |
| 29 | + {{ $root := .root }} |
| 30 | + {{ $site := .site }} |
| 31 | + {{ $currentPage := .currentPage }} |
| 32 | + {{ $firstInSection := (index $root 0) }} |
| 33 | + {{ $isRootSection := eq $firstInSection.Parent .site.Home }} |
| 34 | + |
| 35 | + {{ if gt (len (where $root.ByWeight "Params.toc_hide" "ne" true)) 0 }} |
| 36 | + |
| 37 | + <ul class="gd-docs-menu-section{{ if .activeSection }} active{{ end }}"> |
| 38 | + {{ range $page := $root.ByWeight }} |
| 39 | + {{ $page := $page.Page }} |
| 40 | + {{ $pageId := replace (replaceRE "^/|/$" "" $page.RelPermalink) "/" "_" }} |
| 41 | + |
| 42 | + {{ if and (not (eq $page.Params.toc_hide true)) (not (eq $page $site.Home)) }} |
| 43 | + {{ $activePage := eq $page $currentPage }} |
| 44 | + {{ $activeSection := or $activePage ($currentPage.IsDescendant $page) }} |
| 45 | + {{ $pageId := replace (replaceRE "^/|/$" "" $page.RelPermalink) "/" "_" }} |
| 46 | + |
| 47 | + <li class="gd-docs-menu-page{{ if $activePage }} active{{ end }}{{ if $page.Params.navSeparator }} gd-docs-menu-page__separator{{ end }}"> |
| 48 | + {{ if $page.Params.navigationLabel }} |
| 49 | + <span class="gd-docs-menu-page__label">{{ $page.LinkTitle }}</span> |
| 50 | + {{ else }} |
| 51 | + <div class="gd-docs-menu-page__title"> |
| 52 | + {{ if $page.Params.externalLink }} |
| 53 | + <a href="{{ $page.Params.externalLink }}" class="gd-docs-menu-page__link" target="_blank">{{ $page.LinkTitle }}</a> |
| 54 | + {{ else }} |
| 55 | + <a href="{{ $page.Permalink }}" class="gd-docs-menu-page__link">{{ $page.LinkTitle }}</a> |
| 56 | + {{ end }} |
| 57 | + |
| 58 | + {{ if $page.Pages }} |
| 59 | + <button |
| 60 | + type="button" |
| 61 | + id="btn-{{ $pageId }}" |
| 62 | + class="gd-docs-menu-page__toggle-btn" |
| 63 | + aria-expanded="{{ if $activeSection }}true{{ else }}false{{ end }}" |
| 64 | + aria-controls="section-{{ $pageId }}" |
| 65 | + aria-label="{{ if $activeSection }}Collapse{{ else }}Expand{{ end }} {{ $page.LinkTitle }} section"> |
| 66 | + <span class="gd-docs-menu-page__chevron"> |
| 67 | + {{ with resources.Get "icons/chevron-menu.svg" }} |
| 68 | + {{ $svg := . | minify }} |
| 69 | + {{ $svg := replace $svg.Content "<svg " "<svg aria-hidden=\"true\" focusable=\"false\" " }} |
| 70 | + {{ $svg | safeHTML }} |
| 71 | + {{ end }} |
| 72 | + </span> |
| 73 | + </button> |
| 74 | + {{ end }} |
| 75 | + </div> |
| 76 | + |
| 77 | + {{ if $page.Pages }} |
| 78 | + <div id="section-{{ $pageId }}" class="gd-docs-menu-section-wrapper{{ if $activeSection }} expanded{{ end }}"> |
| 79 | + {{ template "section-tree-nav-sections" (dict "root" $page.Pages "currentPage" $currentPage "activeSection" $activeSection "site" $site) }} |
| 80 | + </div> |
| 81 | + {{ end }} |
| 82 | + {{ end }} |
| 83 | + </li> |
| 84 | + |
| 85 | + {{ if and $page.Params.navigationLabel $page.Pages }} |
| 86 | + <li class="gd-docs-menu-page"> |
| 87 | + {{ template "section-tree-nav-sections" (dict "root" $page.Pages "currentPage" $currentPage "activeSection" $activeSection "site" $site) }} |
| 88 | + </li> |
| 89 | + {{ end }} |
| 90 | + {{ end }} |
| 91 | + {{ end }} |
| 92 | + </ul> |
| 93 | + {{ end }} |
| 94 | +{{ end }} |
0 commit comments