Skip to content

Commit

Permalink
docs/website: make "outdated version" banner red if ancient
Browse files Browse the repository at this point in the history
Where "ancient" means it's not among the latest five releases.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
  • Loading branch information
srenatus committed Nov 2, 2022
1 parent 94f8bc7 commit 370da0a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
15 changes: 12 additions & 3 deletions docs/website/layouts/partials/docs/article.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
{{ $releases := site.Data.releases }}
{{ $version := index (split .File.Path "/") 1 }}
{{ $latest := printf "%s" (index $releases 1) }}
{{- if eq (len site.Data.releases) 1 -}}
{{- if eq (len $releases) 1 -}}
{{- $latest = "(dev preview)" -}}
{{- end -}}
{{ $version := index (split .File.Path "/") 1 }}

{{ $rank := 1 }}
{{- range $index, $ver := $releases -}}
{{- if eq $ver $version -}}
{{ $rank = $index }}
{{- end -}}
{{- end -}}
{{ $ancient := gt $rank 5 }}

<article class="article">
{{- if (eq $version "edge") }}
<div class="message is-danger">
Expand All @@ -12,7 +21,7 @@
</div>
</div>
{{- else if (and (ne $version "latest") (ne $version $latest)) }}
<div class="message is-warning">
<div class="message {{ cond $ancient "is-danger" "is-warning"}}">
<div class="message-body">
These are the docs for an older version of OPA. Latest stable release is <a href="/docs/latest">{{ $latest }}</a>
</div>
Expand Down
22 changes: 15 additions & 7 deletions docs/website/layouts/partials/docs/dashboard-panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
{{ $version := index (split .File.Path "/") 1 }}
{{ $page := trim .RelPermalink "/" }}
{{ $isLatest := or (eq $version $latest) (eq $version "latest") }}

{{ $rank := 1 }}
{{- range $index, $ver := $releases -}}
{{- if eq $ver $version -}}
{{ $rank = $index }}
{{- end -}}
{{- end -}}
{{ $ancient := gt $rank 5 }}
<div class="dashboard-panel left has-background-white-bis is-hidden-touch">
<div class="dashboard-panel-header has-text-centered">
<div class="dashboard-panel-header-logo">
Expand All @@ -27,16 +35,16 @@
</span>
{{ if $isLatest }}
<span class="tag latest-tag is-success is-small has-text-weight-bold">
latest
</span>
latest
</span>
{{ else if (eq $version "edge") }}
<span class="tag latest-tag is-danger is-small has-text-weight-bold">
pre-release
</span>
pre-release
</span>
{{ else }}
<span class="tag latest-tag is-warning is-small has-text-weight-bold">
older
</span>
<span class="tag latest-tag {{ cond $ancient "is-danger" "is-warning"}} is-small has-text-weight-bold">
older
</span>
{{ end }}
<span class="icon is-small">
<i class="fas fa-angle-down" aria-hidden="true"></i>
Expand Down

0 comments on commit 370da0a

Please sign in to comment.