{{ $versions  := site.Params.versions }}
{{ $primary   := index (where $versions ".primary" true) 0 }}
{{ $menu      := site.Menus.main }}

<nav class="navbar navbar-top navbar-top-fixed" role="navigation" aria-label="main navigation">
  <div class="container is-fluid">
    
    <div class="navbar-brand">
      <a href="/">
        {{ partial "logo.html" . }}
      </a>
    </div>

    <!-- desktop menu -->
    <div class="navbar-menu is-centered" id="navMenuDocumentation">
      {{ range $menu }}
        {{ if in (print .URL) "http"}}
          <a href="{{ .URL }}" class
          ="navbar-item external" target="_blank">
            {{ .Name }} <span class="icon"><i class="mdi mdi-open-in-new"></i></span>
          </a>
        {{ else }}
          <a href="{{ .URL | relLangURL }}" class="navbar-item">
            {{ .Name }}
          </a>
        {{ end }}
      {{ end }}
    </div>

    <div class="navbar-end is-hidden-mobile">
      <ul class="is-pulled-right">
        
        <!-- l18n -->
        {{ if .Site.IsMultiLingual }}
        <li class="versioner l18ner navbar-item has-dropdown is-hoverable">
          <a data-dropdown="drop1" aria-controls="drop1" aria-expanded="false" class="versioner-trigger navbar-link">
            {{ .Language.LanguageName }} <i class="fa fa-caret-down"></i>
          </a>

          <ul id="drop1" class="navbar-dropdown dropdown-menu f-dropdown" data-dropdown-content aria-hidden="true" tabindex="-1">
            {{ $siteLanguages := .Site.Languages}}
            {{ $pageLang := .Page.Lang}}
            {{ range .Page.AllTranslations }}
                {{ $translation := .}}
                {{ range $siteLanguages }}
                    {{ if eq $translation.Lang .Lang }}
                      {{ $selected := false }}
                      {{ if eq $pageLang .Lang}}
                          <li class="navbar-item"><a href="{{ $translation.URL }}" class="active">{{ .LanguageName }}</a></li>
                      {{ else }}
                          <li class="navbar-item"><a href="{{ $translation.URL }}">{{ .LanguageName }}</a></li>
                      {{ end }}
                    {{ end }}

                  {{ else }}
                {{ end }}
            {{ end }}
            <li class="navbar-item l18n-prompt"><a href="{{ T "action_translate_link" }}"><small>{{ T "action_translate" }}</small></a></li>
          </ul>
        </li>
        {{ else }}
        {{ end }}
        
        <li class="versioner navbar-item has-dropdown is-hoverable">
          {{ with $primary }}
          <a data-dropdown="drop1" aria-controls="drop1" aria-expanded="false" class="versioner-trigger navbar-link">
            {{ .version }}{{ with .patch }} {{ end }} <i class="fa fa-caret-down"></i>
          </a>
          {{ end }}
    
          <ul id="drop1" class="navbar-dropdown dropdown-menu f-dropdown" data-dropdown-content aria-hidden="true" tabindex="-1">
            {{ range $versions }}
            <li>
              <a href="{{ .url }}" class="navbar-item">
                {{ .version }}{{ with .patch }} <em>{{ . }}</em>{{ end }}
              </a>
            </li>
            {{ end }}
          </ul>
        </li>
        <li>
          <a class="button not-fixed is-outlined" href="{{ T "action_get_started_link" }}">{{ T "action_get_started" }}</a>
        </li>
      </ul>
    </div>
  </div>
</nav>
