{{ $docsHome   := .CurrentSection }}
{{ $allDocs    := where site.RegularPages "Section" "docs" }}
{{ $docs       := where $allDocs ".Params.kind" "eq" "documentation" }}
{{ $kubernetes := where $allDocs ".Params.kind" "eq" "kubernetes" }}
{{ $tutorials  := where $allDocs ".Params.kind" "eq" "tutorial" }}
{{ $operations := where $allDocs ".Params.kind" "eq" "operations" }}
{{ $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" "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" "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">
  Support
</span>

<a class="docs-nav-item" href="https://www.openpolicyagent.org/support.html">
  Enterprise and Commercial
</a>
