docs-v2/layouts/shortcodes/latest-cli.html

13 lines
682 B
HTML
Raw Normal View History

{{- $scratch := newScratch -}}
{{- $productPathData := findRE "[^/]+.*?" .Page.RelPermalink -}}
{{- $parsedVersion := replaceRE "v" "" (index $productPathData 1) -}}
{{- $versionArg := .Get "version" | default "" -}}
{{- $latestVersion := replaceRE "v" "" (index .Site.Data.products.influxdb "latest") -}}
{{- $version := cond (gt (len $versionArg) 0) $versionArg $parsedVersion -}}
{{- $cliVersions := index .Site.Data.products.influxdb "latest_cli" -}}
{{- if eq $version "cloud" -}}
{{- $scratch.Set "cliVersion" (index $cliVersions $latestVersion) -}}
{{- else -}}
{{- $scratch.Set "cliVersion" (index $cliVersions $version) -}}
{{- end -}}
{{- $scratch.Get "cliVersion" -}}