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

33 lines
1.4 KiB
HTML

{{- $cli := .Get "cli" | default false -}}
{{- $productArg := .Get "product" | default "" -}}
{{- $versionArg := .Get "version" | default "" -}}
{{- /* Use shortcode product arg if provided, otherwise cascade */ -}}
{{- $productData := dict -}}
{{- if gt (len $productArg) 0 -}}
{{- $productData = index .Site.Data.products $productArg -}}
{{- else -}}
{{- $productData = partial "product/get-data.html" . -}}
{{- end -}}
{{- $version := cond (gt (len $versionArg) 0) $versionArg .Page.Params.version -}}
{{- if $cli -}}
{{- /* CLI versions use influxdb's latest_cli map */ -}}
{{- $cliVersions := index .Site.Data.products.influxdb "latest_cli" -}}
{{- $influxdbLatest := replaceRE `\..*$` "" (index .Site.Data.products.influxdb "latest") -}}
{{- if or (eq $version "cloud") (eq $version "cloud-serverless") -}}
{{- .Store.Set "patchVersion" (index $cliVersions $influxdbLatest) -}}
{{- else -}}
{{- .Store.Set "patchVersion" (index $cliVersions $version) -}}
{{- end -}}
{{- else -}}
{{- /* For products with a single latest_patch (influxdb3), use it directly */ -}}
{{- with $productData.latest_patch -}}
{{- $.Store.Set "patchVersion" . -}}
{{- else -}}
{{- /* For multi-version products, look up by version key */ -}}
{{- with $productData.latest_patches -}}
{{- $.Store.Set "patchVersion" (index . $version) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- .Store.Get "patchVersion" -}}