docs-v2/layouts/partials/sidebar.html

112 lines
4.8 KiB
HTML

{{ $currentPage := . }}
{{ $productPathData := findRE "[^/]+.*?" .RelPermalink }}
{{ $product := index $productPathData 0 }}
{{ $productName := (index .Site.Data.products $product).name }}
{{ $currentVersion := index $productPathData 1 }}
<!-- Menu Key -->
{{ .Scratch.Set "menuKey" "menu"}}
{{ if eq $product "platform" }}
{{ .Scratch.Set "menuKey" "platform" }}
{{ else if eq $product "resources" }}
{{ .Scratch.Set "menuKey" "resources" }}
{{ else if in $currentVersion "serverless" }}
{{ .Scratch.Set "menuKey" "influxdb3_cloud_serverless" }}
{{ else if in $currentVersion "dedicated" }}
{{ .Scratch.Set "menuKey" "influxdb3_cloud_dedicated" }}
{{ else if eq $currentVersion "clustered" }}
{{ .Scratch.Set "menuKey" "influxdb3_clustered" }}
{{ else }}
{{ .Scratch.Set "menuKey" (print $product "_" $currentVersion) }}
{{ end }}
{{ $menuKey := .Scratch.Get "menuKey" }}
<!-- Search placeholder -->
{{ .Scratch.Set "searchPlaceholder" "Search"}}
{{ $fluxBlacklist := slice "cloud-serverless" "cloud-dedicated" "clustered" "v3" "pro" }}
{{ $influxdbProductKey := print "influxdb_" (replaceRE "-" "_" $currentVersion) }}
{{ if and (eq (index .Site.Data.products $product).name nil) (eq (len (findRE `v[1-3]` $currentVersion nil)) 0) }}
{{ .Scratch.Set "searchPlaceholder" "Search the docs" }}
{{ else if (eq $currentVersion nil) }}
{{ .Scratch.Set "searchPlaceholder" (print "Search " (index .Site.Data.products $product).name) }}
{{ else if eq $product "influxdb" }}
{{ if eq $currentVersion "v3" }}
{{ .Scratch.Set "searchPlaceholder" "Search InfluxDB OSS v3" }}
{{ else if not (in $fluxBlacklist $currentVersion) }}
{{ .Scratch.Set "searchPlaceholder" (print "Search " (index .Site.Data.products $product).name " " (cond (in $currentVersion "v") $currentVersion (title $currentVersion)) " & Flux") }}
{{ else }}
{{ .Scratch.Set "searchPlaceholder" (print "Search " (index .Site.Data.products $influxdbProductKey).name) }}
{{ end }}
{{ else }}
{{ .Scratch.Set "searchPlaceholder" (print "Search " (index .Site.Data.products $product).name) }}
{{ end }}
{{ $searchPlaceholder := .Scratch.Get "searchPlaceholder" }}
<aside class="sidebar">
{{ partial "sidebar/sidebar-toggle.html" (dict "state" "Close") }}
<div class="search-and-nav-toggle">
<div class="sidebar--search">
<input class="sidebar--search-field"
id="algolia-search-input"
type="text"
accesskey="s"
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
dir="auto"
placeholder='{{ $searchPlaceholder }}'>
</div>
<a id="contents-toggle-btn" href="#">
<span class="toggle-hamburger"></span>
</a>
</div>
<ul id="nav-tree">
{{ $mainMenu := (index .Site.Menus $menuKey) }}
{{ $refMenu := (index .Site.Menus (print $menuKey "_ref")) }}
{{ $platformMenu := .Site.Menus.platform }}
<!-- Product Main Navigation -->
{{ partial "sidebar/nested-menu" (dict "page" $currentPage "menu" $mainMenu) . }}
<!-- Product Reference Navigation -->
{{ if gt (len $refMenu) 0 }}
<h4 class="reference">Reference</h4>
{{ partial "sidebar/nested-menu" (dict "page" $currentPage "menu" $refMenu) . }}
{{ end }}
<!-- Flux links for InfluxDB docs -->
{{ $fluxWhitelist := `influxdb\/((v(1\.[7-8]))|(v(2\.[0-9]))|cloud)$` }}
{{ $productAndVersion := print $product "/" $currentVersion }}
{{ $latestFlux := $.Site.Data.products.flux.latest }}
{{ if gt (len (findRE $fluxWhitelist $productAndVersion)) 0 }}
<h4 class="flux">Flux</h4>
<li class="nav-category"><a href="/flux/{{ $latestFlux }}/">Flux {{ $latestFlux }} Documentation</a></li>
<li class="nav-category"><a href="/flux/{{ $latestFlux }}/get-started/">Get started with Flux</a></li>
<li class="nav-category"><a href="/flux/{{ $latestFlux }}/stdlib/">Flux standard library</a></li>
{{ end }}
<!-- Platform menu for 1.x docs -->
{{ $platformWhitelist := `telegraf|chronograf|kapacitor|enterprise_influxdb|influxdb_1` }}
{{ if gt (len (findRE $platformWhitelist $menuKey)) 0 }}
<h4 class="platform">InfluxData Platform</h4>
{{ partial "sidebar/nested-menu" (dict "page" $currentPage "menu" $platformMenu) . }}
{{ end }}
<!-- Additional resources for all docs -->
{{ $resourcesProductWhitelist := slice "platform" "influxdb" "enterprise_influxdb" "telegraf" "chronograf" "kapacitor" "flux" }}
{{ $resourcesVersionWhitelist := `(?:v\d\.(?:\d{1,2}|x))|cloud$` }}
{{ if and (in $resourcesProductWhitelist $product) (gt (len (findRE $resourcesVersionWhitelist $currentVersion)) 0) }}
<h4 class="resources">Additional resources</h4>
<li class="nav-category"><a href="/resources/videos/">Videos</a></li>
<li class="nav-category"><a href="/resources/how-to-guides/">How-to Guides</a></li>
{{ end }}
</ul>
</aside>