2
2
{{ $product := index $productPathData 0 }}
3
3
{{ $version := index $productPathData 1 | default "0"}}
4
4
{{ $productKey := cond (eq $product "influxdb3") (print "influxdb3_" (replaceRE "-" "_" $version)) $product }}
5
- {{ $productName := cond (isset (index .Site.Data.products $productKey) "altname") (index .Site.Data.products $productKey).altname (index .Site.Data.products $productKey).name }}
6
5
7
- {{ $stableVersion := (replaceRE `\.[0-9x]+$` "" (index .Site.Data.products $product).latest) }}
8
- {{ $stableVersionURL := replaceRE `v[1-3]` $stableVersion .RelPermalink }}
9
- {{ $stableDefaultURL := print "/" $product "/" $stableVersion "/" }}
6
+ <!-- Initialize version variables -->
7
+ {{ $successorInfo := dict "exists" false }}
8
+ {{ $productName := $product | humanize }}
9
+ {{ $stableVersion := "" }}
10
+ {{ $stableVersionURL := "" }}
11
+ {{ $stableDefaultURL := "" }}
12
+
13
+ <!-- Get current product name -->
14
+ {{ if isset .Site.Data.products $productKey }}
15
+ {{ $productName = cond (isset (index .Site.Data.products $productKey) "altname") (index .Site.Data.products $productKey).altname (index .Site.Data.products $productKey).name }}
16
+ {{ end }}
17
+
18
+ <!-- Check for successor and get version information -->
19
+ {{ if and (isset .Site.Data.products $productKey) (isset (index .Site.Data.products $productKey) "succeeded_by") }}
20
+ {{ $successorKey := (index .Site.Data.products $productKey).succeeded_by }}
21
+
22
+ {{ if and $successorKey (isset .Site.Data.products $successorKey) }}
23
+ <!-- Successor exists and is valid -->
24
+ {{ $successorInfo = dict
25
+ "exists" true
26
+ "key" $successorKey
27
+ "name" (cond (isset (index .Site.Data.products $successorKey) "altname")
28
+ (index .Site.Data.products $successorKey).altname
29
+ (index .Site.Data.products $successorKey).name)
30
+ "version" (replaceRE `\.[0-9x]+$` "" (index .Site.Data.products $successorKey).latest)
31
+ "namespace" (index .Site.Data.products $successorKey).namespace
32
+ }}
33
+
34
+ <!-- Set stable version to successor version -->
35
+ {{ $stableVersion = $successorInfo.version }}
36
+ {{ $stableVersionURL = print "/" $successorInfo.namespace "/" $stableVersion "/" }}
37
+ {{ $stableDefaultURL = $stableVersionURL }}
38
+ {{ end }}
39
+ {{ else if isset .Site.Data.products $product }}
40
+ <!-- No successor, use current product's latest version -->
41
+ {{ $stableVersion = (replaceRE `\.[0-9x]+$` "" (index .Site.Data.products $product).latest) }}
42
+ {{ $stableVersionURL = replaceRE `v[1-3]` $stableVersion .RelPermalink }}
43
+ {{ $stableDefaultURL = print "/" $product "/" $stableVersion "/" }}
44
+ {{ end }}
45
+
10
46
{{ $stableEquivalentURL := index .Page.Params.alt_links $stableVersion | default "does-not-exist" }}
11
47
{{ $stableEquivalentPage := .GetPage (replaceRE `\/$` "" $stableEquivalentURL) }}
12
48
{{ $stablePageExists := gt (len $stableEquivalentPage.Title) 0 }}
13
49
{{ $productWhiteList := slice "telegraf" "influxdb" "chronograf" "kapacitor" "flux" }}
14
50
{{ $isMultiVersion := in (print "/" $version) "/v" }}
15
51
16
52
{{ if and (in $productWhiteList $product) $isMultiVersion }}
17
- <!-- Check if the current version is less than the stable version -->
18
- {{ if lt (int (replaceRE `[a-z]` "" $version)) (int (replaceRE `[a-z]` "" $stableVersion)) }}
53
+ {{ if $successorInfo.exists }}
54
+ <!-- Show callout for product with successor -->
19
55
< div class ="warn block old-version ">
20
56
< p >
21
57
This page documents an earlier version of {{ $productName }}.
22
- < a href ="/{{ $product }}/{{ $stableVersion }}/ "> {{ $productName }} {{ $stableVersion }}</ a > is the latest stable version.
23
- <!-- Check if page exists in latest major version docs -->
24
- {{ if gt (len (.GetPage ((replaceRE `v[1-3]` $stableVersion .RelPermalink) | replaceRE `\/$` "")).Title) 0 }}
25
- < a href ="{{ $stableVersionURL }} "> View this page in the {{ $stableVersion }} documentation</ a > .
26
- <!-- Check if the stable equivalent page exists -->
27
- {{ else if $stablePageExists }}
28
- < span style ="margin-right:.25rem "> See the equivalent < strong > InfluxDB {{ $stableVersion }}</ strong > documentation:</ span > < a href ="{{ $stableEquivalentPage.RelPermalink }} "> {{ $stableEquivalentPage.Title | .RenderString }}</ a > .
29
- {{ else }}
30
- See the < a href ="{{ $stableDefaultURL }} "> InfluxDB {{ $stableVersion }} documentation</ a > .
31
- {{ end }}
58
+ < a href ="{{ $stableDefaultURL }} "> {{ $successorInfo.name }}</ a > is the latest stable version.
32
59
</ p >
33
60
</ div >
61
+ {{ else if $stableVersion }}
62
+ <!-- Show callout for product with newer version (no successor) -->
63
+ {{ if lt (int (replaceRE `[a-z]` "" $version)) (int (replaceRE `[a-z]` "" $stableVersion)) }}
64
+ < div class ="warn block old-version ">
65
+ < p >
66
+ This page documents an earlier version of {{ $productName }}.
67
+ < a href ="/{{ $product }}/{{ $stableVersion }}/ "> {{ $productName }} {{ $stableVersion }}</ a > is the latest stable version.
68
+
69
+ <!-- Handle page navigation options -->
70
+ {{ if gt (len (.GetPage ((replaceRE `v[1-3]` $stableVersion .RelPermalink) | replaceRE `\/$` "")).Title) 0 }}
71
+ < a href ="{{ $stableVersionURL }} "> View this page in the {{ $stableVersion }} documentation</ a > .
72
+ {{ else if $stablePageExists }}
73
+ < span style ="margin-right:.25rem "> See the equivalent < strong > {{ $productName }} {{ $stableVersion }}</ strong > documentation:</ span > < a href ="{{ $stableEquivalentPage.RelPermalink }} "> {{ $stableEquivalentPage.Title | .RenderString }}</ a > .
74
+ {{ else }}
75
+ See the < a href ="{{ $stableDefaultURL }} "> {{ $productName }} {{ $stableVersion }} documentation</ a > .
76
+ {{ end }}
77
+ </ p >
78
+ </ div >
79
+ {{ end }}
34
80
{{ end }}
35
- {{ end }}
36
-
37
- {{ if and .Page.Params.v2 (eq (findRE `v[1-3]` $version) (findRE `v[1-3]` $stableVersion)) }}
38
- < div class ="note block old-version ">
39
- < p >
40
- {{ if $stablePageExists }}
41
- < span style ="margin-right:.25rem "> See the equivalent < strong > InfluxDB {{ $stableVersion }}</ strong > documentation:</ span > < a href ="{{ $stableEquivalentPage.RelPermalink }} "> {{ $stableEquivalentPage.Title | .RenderString }}</ a > .
42
- {{ else }}
43
- See the < a href ="{{ $stableEquivalentURL }} "> equivalent InfluxDB {{ $stableVersion }} documentation</ a > .
44
- {{ end }}
45
- </ p >
46
- </ div >
47
- {{ end }}
81
+ {{ end }}
0 commit comments