{{ $home        := site.BaseURL }}
{{ $logo        := site.Params.logos.navbar }}
{{ $social      := site.Params.social }}
{{ $github      := $social.github }}
{{ $discussions := $social.discussions }}
{{ $twitter     := printf "https://twitter.com/%s" $social.twitter }}
{{ $medium      := $social.medium }}
{{ $slack       := $social.slack }}
{{ $docsHome    := .CurrentSection }}
{{ $allDocs     := where site.RegularPages "Section" "docs" }}
{{ $docs        := where $allDocs ".Params.kind" "eq" "documentation" }}
{{ $kubernetes  := where $allDocs ".Params.kind" "eq" "kubernetes" }}
{{ $envoy       := where $allDocs ".Params.kind" "eq" "envoy" }}
{{ $tutorials   := where $allDocs ".Params.kind" "eq" "tutorial" }}
{{ $operations  := where $allDocs ".Params.kind" "eq" "operations" }}
{{ $management  := where $allDocs ".Params.kind" "eq" "management" }}
{{ $contrib     := where $allDocs ".Params.kind" "eq" "contrib" }}
{{ $misc        := where $allDocs ".Params.kind" "eq" "misc" }}
{{ $version     := index (split .File.Path "/") 1 }}
{{ $pageUrl     := .URL }}
<nav class="navbar is-primary">
  <div class="navbar-brand is-hidden-tablet">
    <a class="navbar-item" href="{{ $home }}">
      <img src="{{ $logo }}">
    </a>

    <a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="mobile-menu">
      <span aria-hidden="true"></span>
      <span aria-hidden="true"></span>
      <span aria-hidden="true"></span>
    </a>
  </div>

  <div class="navbar-menu is-hidden-tablet" id="mobile-menu">
    <div class="navbar-start">
      <span class="navbar-item is-size-5 has-text-weight-light is-uppercase">
        Core Docs
      </span>

      <a class="navbar-item" href="{{ $docsHome.URL }}">
        {{ $docsHome.Name }}
      </a>

      {{ range $docs }}
      {{ partial "docs/navbar-link.html" (dict "ctx" . "pageUrl" $pageUrl "version" $version) }}
      {{ end }}

      {{ partial "docs/navbar-section.html" ( dict "ctx" . "sectionTitle" "Kubernetes" "section" $kubernetes "pageUrl" $pageUrl "version" $version ) }}

      {{ partial "docs/navbar-section.html" ( dict "ctx" . "sectionTitle" "Envoy" "section" $envoy "pageUrl" $pageUrl "version" $version ) }}

      {{ partial "docs/navbar-section.html" ( dict "ctx" . "sectionTitle" "Other Use Cases" "section" $tutorials "pageUrl" $pageUrl "version" $version ) }}

      {{ partial "docs/navbar-section.html" ( dict "ctx" . "sectionTitle" "Operations" "section" $operations "pageUrl" $pageUrl "version" $version ) }}

      {{ partial "docs/navbar-section.html" ( dict "ctx" . "sectionTitle" "Management APIs" "section" $management "pageUrl" $pageUrl "version" $version ) }}

      {{ partial "docs/navbar-section.html" ( dict "ctx" . "sectionTitle" "Contributing" "section" $contrib "pageUrl" $pageUrl "version" $version ) }}

      {{ partial "docs/navbar-section.html" ( dict "ctx" . "sectionTitle" "Miscellaneous" "section" $misc "pageUrl" $pageUrl "version" $version ) }}

      <br />

      <span class="navbar-item is-size-5 has-text-weight-light is-uppercase">
        Support
      </span>
      <a class="navbar-item" href="/support">
        Enterprise and Commercial
      </a>
      <a class="navbar-item" href="/community">
        Community
      </a>
    </div>

    <div class="navbar-end">
      <div class="navbar-item">
        <div class="buttons">
          <a class="button is-primary" href="{{ $github }}" target="_blank">
            <span class="icon has-text-white-bis">
              <i class="fab fa-github"></i>
            </span>
          </a>

          <a class="button is-primary" href="{{ $discussions }}" target="_blank">
            <span class="icon has-text-white-bis">
              <i class="fas fa-comments"></i>
            </span>
          </a>

          <a class="button is-primary" href="{{ $twitter }}" target="_blank">
            <span class="icon has-text-white-bis">
              <i class="fab fa-twitter"></i>
            </span>
          </a>

          <a class="button is-primary" href="{{ $medium }}" target="_blank">
            <span class="icon has-text-white-bis">
              <i class="fab fa-medium"></i>
            </span>
          </a>

          <a class="button is-primary" href="{{ $slack }}" target="_blank">
            <span class="icon has-text-white-bis">
              <i class="fab fa-slack"></i>
            </span>
          </a>
        </div>
      </div>
    </div>
  </div>

  <div class="navbar-menu">
    <div class="navbar-end">
      <div class="navbar-item">
        <p class="control has-icons-right">
          <input class="input" type="search" id="search-bar" placeholder="Search...">
          <span class="icon is-small is-right">
            <icon />
          </span>
        </p>
      </div>

      <div class="navbar-item">
        <a class="button is-success has-text-weight-semibold" href="https://play.openpolicyagent.org/" target="_blank" title="Playground">
          Playground
        </a>
      </div>

      <a class="navbar-item" href="{{ $github }}" target="_blank" title="GitHub">
        <span class="icon has-text-white-bis">
          <i class="fab fa-github"></i>
        </span>
      </a>

      <a class="navbar-item" href="{{ $discussions }}" target="_blank" title="GitHub Discussions">
        <span class="icon has-text-white-bis">
          <i class="fas fa-comments"></i>
        </span>
      </a>

      <a class="navbar-item" href="{{ $twitter }}" target="_blank" title="Twitter">
        <span class="icon has-text-white-bis">
          <i class="fab fa-twitter"></i>
        </span>
      </a>

      <a class="navbar-item" href="{{ $medium }}" target="_blank" title="Medium">
        <span class="icon has-text-white-bis">
          <i class="fab fa-medium"></i>
        </span>
      </a>

      <a class="navbar-item" href="{{ $slack }}" target="_blank" title="Slack">
        <span class="icon has-text-white-bis">
          <i class="fab fa-slack"></i>
        </span>
      </a>
    </div>
  </div>
</nav>