Maintain product and version switcher contexts (#2458)

* maintain product and version switcher contexts, closes #2452

* updated version selector self link
pull/2462/head
Scott Anderson 2021-04-29 14:22:15 -06:00 committed by GitHub
parent 43d49365b2
commit afda3fb93b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -16,8 +16,11 @@
{{ end }}
<ul class="item-list">
{{ range sort .Site.Data.products "list_order" "desc" }}
{{ $isCurrentProduct := and (eq .namespace $product) (in .versions $currentVersion) }}
{{ $scratch.Set "link" (print "/" .namespace "/" .latest "/") }}
{{ if and $isCloud (eq .altname "InfluxDB OSS")}}
{{ if $isCurrentProduct }}
{{ $scratch.Set "link" "" }}
{{ else if and $isCloud (eq .altname "InfluxDB OSS")}}
{{ $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 }}
@ -30,7 +33,7 @@
{{ end }}
{{ $link := $scratch.Get "link" }}
<li>
<a href='{{ $link }}' {{ if and (eq .namespace $product) (in .versions $currentVersion) }}class="active"{{ end }}>{{ if .altname }}{{.altname}}{{ else }}{{ .name }}{{ end }}</a>
<a href='{{ $link }}' {{ if $isCurrentProduct }}class="active"{{ end }}>{{ if .altname }}{{.altname}}{{ else }}{{ .name }}{{ end }}</a>
</li>
{{ end }}
</ul>

View File

@ -14,6 +14,8 @@
{{ $altVersionPage := $.GetPage ((replaceRE $currentVersion . $.Page.RelPermalink) | replaceRE `\/$` "") }}
{{ if gt (len $altVersionPage.Title) 0 }}
{{ $scratch.Set "link" $altVersionPage.RelPermalink }}
{{ else if eq . $currentVersion }}
{{ $scratch.Set "link" "" }}
{{ end }}
{{ $link := $scratch.Get "link" }}
<li>