istio.io/layouts/shortcodes/relnote_links.html

65 lines
2.6 KiB
HTML

{{ $dir_name := path.Base .Page.Dir }}
{{ $parts := split $dir_name "." }}
{{ $short_version := $dir_name }}
{{ $full_version := printf "%s.0" $dir_name }}
{{ $old_full_version := $full_version }}
{{ $patch := false }}
{{ if ne (len $parts) 2 }}
{{ $short_version = printf "%s.%s" (index $parts 0) (index $parts 1) }}
{{ $full_version = printf "%s.%s.%s" (index $parts 0) (index $parts 1) (index $parts 2) }}
{{ $old_full_version = printf "%s.%s.%d" (index $parts 0) (index $parts 1) (sub (int (index $parts 2)) 1) }}
{{ $patch = true }}
{{ end }}
{{ $first := index .Site.Data.releases 0 }}
{{ $second := index .Site.Data.releases 1 }}
{{ $type_of_note := "current" }}
{{ if eq $short_version $first.name }}
{{ $type_of_note = "prelim" }}
{{ else if eq $short_version $second.name }}
{{ $type_of_note = "current" }}
{{ else }}
{{ $type_of_note = "archive" }}
{{ end }}
<script>
document.addEventListener("DOMContentLoaded", function() {
window.setTimeout(function() {
document.getElementById('buttons').style.opacity = "1";
}, 250);
});
</script>
<div class="relnote-links">
<div id="buttons">
{{ if .Site.Data.args.preliminary }}
{{ if ne $type_of_note "prelim" }}
<a class="btn" href="https://github.com/istio/istio/releases/tag/{{ $full_version }}">{{ printf (i18n "relnote_download") $dir_name }}</a>
{{ if eq $type_of_note "archive" }}
<a class="btn" href="https://archive.istio.io/v{{ $short_version }}">{{ printf (i18n "relnote_docs") $dir_name }}</a>
{{ else }}
<a class="btn" href="https://istio.io">{{ printf (i18n "relnote_docs") $dir_name }}</a>
{{ end }}
{{ if $patch }}
<a class="btn" href="https://github.com/istio/istio/compare/{{ $old_full_version }}...{{ $full_version }}">{{ printf (i18n "relnote_changes") $dir_name }}</a>
{{ end }}
{{ end }}
{{ else }}
<a class="btn" href="https://github.com/istio/istio/releases/tag/{{ $full_version }}">{{ printf (i18n "relnote_download") $dir_name }}</a>
{{ if (ne .Site.Data.args.version $short_version) }}
<a class="btn" href="https://archive.istio.io/v{{ $short_version }}">{{ printf (i18n "relnote_docs") $dir_name }}</a>
{{ end }}
{{ if $patch }}
<a class="btn" href="https://github.com/istio/istio/compare/{{ $old_full_version }}...{{ $full_version }}">{{ printf (i18n "relnote_changes") $dir_name }}</a>
{{ end }}
{{ end }}
</div>
</div>