Improve release note links in the release-1.0 branch. (#2598)

This commit is contained in:
Martin Taillefer 2018-09-12 12:15:10 -07:00 committed by GitHub
parent 22d3b9e72d
commit 7274a1c0ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 20 deletions

View File

@ -1,30 +1,29 @@
{{ $dir_name := index (last 2 (split .Page.Dir "/" )) 0 }}
{{ $parts := split $dir_name "." }}
{{ if eq (len $parts) 2 }}
{{ .Scratch.Set "short_version" $dir_name }}
{{ .Scratch.Set "full_version" (printf "%s.0" $dir_name) }}
{{ .Scratch.Set "patch" false }}
{{ else }}
{{ .Scratch.Set "short_version" (printf "%s.%s" (index $parts 0) (index $parts 1)) }}
{{ .Scratch.Set "full_version" $dir_name }}
{{ .Scratch.Set "patch" true }}
{{ $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 }}
{{ $short_version := .Scratch.Get "short_version" }}
{{ $full_version := .Scratch.Get "full_version" }}
{{ $patch := .Scratch.Get "patch" }}
{{ $first := index .Site.Data.releases 0 }}
{{ $second := index .Site.Data.releases 1 }}
{{ .Scratch.Set "type_of_note" "current" }}
{{ $type_of_note := "current" }}
{{ if eq $short_version $first.name }}
{{ .Scratch.Set "type_of_note" "prelim" }}
{{ $type_of_note = "prelim" }}
{{ else if eq $short_version $second.name }}
{{ .Scratch.Set "type_of_note" "current" }}
{{ $type_of_note = "current" }}
{{ else }}
{{ .Scratch.Set "type_of_note" "archive" }}
{{ $type_of_note = "archive" }}
{{ end }}
{{ $type_of_note := .Scratch.Get "type_of_note" }}
<script>
document.addEventListener("DOMContentLoaded", function() {
@ -47,8 +46,8 @@
<a class="btn btn-istio" href="https://istio.io">{{ $dir_name }} DOCS</a>
{{ end }}
{{ if $patch}}
<a class="btn btn-istio" href="https://github.com/istio/istio/compare/{{ $short_version }}.0...{{ $full_version }}">{{ $dir_name }} CHANGES</a>
{{ if $patch }}
<a class="btn btn-istio" href="https://github.com/istio/istio/compare/{{ $old_full_version }}...{{ $full_version }}">CHANGES IN {{ $dir_name }}</a>
{{ end }}
{{ end }}
{{ else }}
@ -58,8 +57,8 @@
<a class="btn btn-istio" href="https://archive.istio.io/v{{ $short_version }}">{{ $dir_name }} DOCS</a>
{{ end }}
{{ if $patch}}
<a class="btn btn-istio" href="https://github.com/istio/istio/compare/{{ $short_version }}.0...{{ $full_version }}">{{ $dir_name }} CHANGES</a>
{{ if $patch }}
<a class="btn btn-istio" href="https://github.com/istio/istio/compare/{{ $old_full_version }}...{{ $full_version }}">CHANGES IN {{ $dir_name }}</a>
{{ end }}
{{ end }}
</div>