fixed page detection on product and version selector templates

pull/1904/head
Scott Anderson 2020-11-30 20:33:09 -07:00
parent 2ea5a281fc
commit 865cf0008d
2 changed files with 10 additions and 3 deletions

View File

@ -18,12 +18,12 @@
{{ range sort .Site.Data.products "list_order" "desc" }}
{{ $scratch.Set "link" (print "/" .namespace "/" .latest "/") }}
{{ if and $isCloud (eq .altname "InfluxDB OSS")}}
{{ $altOSSPage := $.GetPage (replaceRE "influxdb/cloud" (print "influxdb/" $.Site.Data.products.influxdb.latest) $.Page.RelPermalink) }}
{{ $altOSSPage := $.GetPage ((replaceRE "influxdb/cloud" (print "influxdb/" $.Site.Data.products.influxdb.latest) $.Page.RelPermalink) | replaceRE `\/$` "") }}
{{ if gt (len $altOSSPage.Title) 0 }}
{{ $scratch.Set "link" $altOSSPage.RelPermalink }}
{{ end }}
{{ else if and $isOSSv2 (eq .altname "InfluxDB Cloud") }}
{{ $altCloudPage := $.GetPage (replaceRE $currentVersion "cloud" $.Page.RelPermalink) }}
{{ $altCloudPage := $.GetPage ((replaceRE $currentVersion "cloud" $.Page.RelPermalink) | replaceRE `\/$` "") }}
{{ if gt (len $altCloudPage.Title) 0 }}
{{ $scratch.Set "link" $altCloudPage.RelPermalink }}
{{ end }}

View File

@ -1,3 +1,4 @@
{{ $scratch := newScratch }}
{{ $productPathData := findRE "[^/]+.*?" .RelPermalink }}
{{ $product := index $productPathData 0 }}
{{ $currentVersion := index $productPathData 1 }}
@ -9,8 +10,14 @@
<ul class="item-list">
<li><a href="https://archive.docs.influxdata.com/{{ $product }}/" class="legacy" target="_blank">older</a></li>
{{ range (index .Site.Data.products $product).versions }}
{{ $scratch.Set "link" (print "/" $product "/" . "/") }}
{{ $altVersionPage := $.GetPage ((replaceRE $currentVersion . $.Page.RelPermalink) | replaceRE `\/$` "") }}
{{ if gt (len $altVersionPage.Title) 0 }}
{{ $scratch.Set "link" $altVersionPage.RelPermalink }}
{{ end }}
{{ $link := $scratch.Get "link" }}
<li>
<a href="/{{ $product }}/{{ . }}/" {{ if eq . $currentVersion }}class="active"{{ end }}>{{ cond (in . "v") . (title .) }}</a>
<a href="{{ $link }}" {{ if eq . $currentVersion }}class="active"{{ end }}>{{ cond (in . "v") . (title .) }}</a>
</li>
{{ end }}
</ul>