docs-v2/layouts/partials/article/stable-version.html

20 lines
894 B
HTML

{{ $productPathData := findRE "[^/]+.*?" .RelPermalink }}
{{ $product := index $productPathData 0 }}
{{ $productName := (index .Site.Data.products $product).name }}
{{ $currentVersion := index $productPathData 1 }}
{{ $stableVersion := (index .Site.Data.products $product).latest }}
{{ $stableVersionURL := replaceRE `v[1-2]\.[0-9]{1,2}` $stableVersion .RelPermalink }}
{{ if lt $currentVersion $stableVersion }}
<div class="warn block old-version">
<p>
This page documents an earlier version of {{ $productName }}.
<a href="/{{ $product }}/{{$stableVersion}}/">{{ $productName }} {{ $stableVersion }}</a> is the latest stable version.<br/>
{{ if eq (findRE `v[1-2]` $currentVersion) (findRE `v[1-2]` $stableVersion) }}
<a href="{{ $stableVersionURL }}">View this page in the {{ $stableVersion }} documentation</a>.
{{ end }}
</p>
</div>
{{ end }}