docs-sidebar.html 1.72 KB
Newer Older
Martijn Cuppens's avatar
Martijn Cuppens committed
1
<nav class="collapse bd-links" id="bd-docs-nav" aria-label="Main navigation">
2
  {{- $url := split .Permalink "/" -}}
XhmikosR's avatar
XhmikosR committed
3
4
  {{- $page_slug := index $url (sub (len $url) 2) -}}

Mark Otto's avatar
Mark Otto committed
5
  <ul class="list-unstyled">
XhmikosR's avatar
XhmikosR committed
6
7
8
9
10
11
12
13
14
15
16
17
  {{- range $group := .Site.Data.nav -}}
    {{- $link := $group.title -}}
    {{- $link_slug := $link | urlize -}}

    {{- if $group.pages -}}
      {{- $link = index $group.pages 0 -}}
      {{- $link_slug = $link.title | urlize -}}
    {{- end -}}

    {{- $group_slug := $group.title | urlize -}}
    {{- $active_group := eq $.Page.Params.group $group_slug }}

XhmikosR's avatar
XhmikosR committed
18
      <li class="bd-sidenav-group my-1{{ if $active_group }} active{{ end }} js-sidenav-group{{ if $group.pages }} has-children{{ end }}">
Mark Otto's avatar
Mark Otto committed
19
20
        <a class="d-inline-flex align-items-center bd-sidenav-group-link" href="/docs/{{ $.Site.Params.docs_version }}/{{ $group_slug }}/{{ if $group.pages }}{{ $link_slug }}/{{ end }}">
          <div>{{- $group.title -}}</div>
XhmikosR's avatar
XhmikosR committed
21
22
        </a>

Mark Otto's avatar
Mark Otto committed
23
        {{- if $group.pages }}
24
        <ul class="nav bd-sidenav flex-column mb-2">
XhmikosR's avatar
XhmikosR committed
25
26
27
28
29
30
31
32
33
34
          {{- range $doc := $group.pages -}}
            {{- $doc_slug := $doc.title | urlize }}
            <li{{ if and $active_group (eq $page_slug $doc_slug) }} class="active bd-sidenav-active"{{ end }}>
              <a href="/docs/{{ $.Site.Params.docs_version }}/{{ $group_slug }}/{{ $doc_slug }}/">
                {{- $doc.title -}}
              </a>
            </li>
          {{- end }}
        </ul>
        {{- end }}
Mark Otto's avatar
Mark Otto committed
35
36
37
38
39
      </li>
    {{- end }}

    <li class="my-3 mx-4 border-top"></li>
    <li class="bd-sidenav-group pl-3">
Mark Otto's avatar
Mark Otto committed
40
      <a class="d-inline-flex align-items-center bd-sidenav-group-link" href="/docs/{{ $.Site.Params.docs_version }}/migration/">
XhmikosR's avatar
XhmikosR committed
41
        Migration
Mark Otto's avatar
Mark Otto committed
42
      </a>
Mark Otto's avatar
Mark Otto committed
43
44
    </li>
  </ul>
XhmikosR's avatar
XhmikosR committed
45
</nav>