{{ $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" }}
{{ $pageUrl    := .URL }}
{{ $isDocsHome := eq .URL $docsHome.URL }}
{{ $version    := index (split .File.Path "/") 1 }}
{{ $latest     := index site.Data.releases 1 }}

<span class="docs-nav-title">
  Core Docs
</span>

{{ $docsHomeVersion := $version }}
{{ if or (eq $version $latest) }}
{{ $docsHomeVersion = "latest" }}
{{ end }}
<a class="docs-nav-item{{ if $isDocsHome }} is-active{{ end }}" href="/docs/{{ $docsHomeVersion }}">
  {{ $docsHome.Name }}
</a>

{{ if $isDocsHome }}
<div class="toc">
  {{ .TableOfContents }}
</div>
{{ end }}

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

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

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

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

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

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

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

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

<a class="docs-nav-item" href="https://play.openpolicyagent.org/">
  Rego Playground
</a>

<hr class="docs-nav-hr" />

<span class="docs-nav-title">
  Community
</span>

<a class="docs-nav-item" href="/support">
  Enterprise and Commercial
</a>
