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

28 lines
1.4 KiB
HTML

{{- $cli := .Get "cli" | default false }}
{{- $productPathData := split .Page.RelPermalink "/" -}}
{{- $parsedProduct := index $productPathData 1 | default "influxdb" -}}
{{- $parsedVersion := index $productPathData 2 -}}
{{- $productArg := .Get "product" | default "" -}}
{{- $versionArg := .Get "version" | default "" -}}
{{- $product := cond (gt (len $productArg) 0) $productArg $parsedProduct -}}
{{- $latestVersion := replaceRE `\..*$` "" (index (index .Site.Data.products $product) "latest") -}}
{{- $version := cond (gt (len $versionArg) 0) $versionArg $parsedVersion -}}
{{- $patchVersions := index (index .Site.Data.products $product) "latest_patches" -}}
{{- $cliVersions := index .Site.Data.products.influxdb "latest_cli" -}}
{{- $isInfluxDB3 := eq $product "influxdb3" -}}
{{- if $cli }}
{{- if eq $version "cloud" -}}
{{- .Store.Set "patchVersion" (index $cliVersions $latestVersion) -}}
{{- else -}}
{{- .Store.Set "patchVersion" (index $cliVersions $version) -}}
{{- end -}}
{{- else -}}
{{- if eq $version "cloud" -}}
{{- .Store.Set "patchVersion" (index $patchVersions $latestVersion) -}}
{{- else if $isInfluxDB3 -}}
{{- .Store.Set "patchVersion" (index .Site.Data.products (print $product "_" $version)).latest_patch -}}
{{- else -}}
{{- .Store.Set "patchVersion" (index $patchVersions $version) -}}
{{- end -}}
{{- end -}}
{{- .Store.Get "patchVersion" -}}