{{ $.Scratch.Set "topLevel" . }}
{{ range $product := $.Site.Sections }}
  {{ range $version := .Sections }}
    {{ range $language := .Sections }}
      {{if $.CurrentSection}}
        {{ if .IsAncestor $.CurrentSection }}
          {{ $.Scratch.Set "topLevel" . }}
        {{end}}
      {{end}}
    {{end}}
  {{end}}
{{end}}

<nav class="bg-default">
  <div class="wrapper row middle-xs">
  <div class="p-v-xs">
      <ul class="dropdown sub-menu unstyled">
        <li class="m-b-0">
          <a href="{{ ($.Scratch.Get "topLevel").Permalink }}" class="btn bg-link p-a-0">
            <span class="p-h-xs">
              {{ range $product := $.Site.Sections }}
                {{ range $version := .Sections }}
                  {{ range $language := .Sections }}
                    {{if $.CurrentSection}}
                      {{ if .IsAncestor $.CurrentSection }}
                        {{ .Params.shortTitle }}
                      {{end}}
                    {{end}}
                  {{end}}
                {{end}}
              {{end}}
            </span>
            <i class="material-icons darken p-a-xs">keyboard_arrow_down</i>
          </a>

          <ul class="sub dropdown-menu bg-white unstyled">
            {{ range $product := $.Site.Sections }}
              {{ range $version := .Sections }}
                {{ range $language := .Sections }}
                  <li class="m-b-0"><a href="{{ .Permalink }}">{{ .Params.shortTitle }}</a></li>
                  {{ if .Params.insertonesix }}
                    <li class="m-b-0"><a href="https://rancher.com/docs/rancher/v1.6/en/" target="blank">Rancher 1.6</a></li>
                  {{end}}
                {{end}}
              {{end}}
            {{end}}

          </ul>
        </li>
      </ul>
  </div>

  <!-- top level nav -->
    <nav>
      <ul class="row unstyled">
      {{ $topLevel := .Scratch.Get "topLevel"}}
      {{ if $topLevel }}
        {{ range $topLevel.Sections }}
          {{ $isCurrent := .IsAncestor $.CurrentSection }}
          {{ if $isCurrent }}
            {{ $.Scratch.Set "secondLevel" . }}
          {{ end }}

          <li class="{{if $isCurrent}}active{{end}} p-a-xs m-b-0"><a href="{{ .Permalink }}">{{ .Title }}</a></li>
        {{ end }}
      {{ end }}
    </ul>
  </nav>
</div>
</nav>
