Skip to content

Commit

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

Also, in, netlify.toml: declare framework for dev. I've found that
adding this live means I can use

    netlify dev --offline

without any further switches. For some reason, I had run into
trouble with "cecil" when using it like that.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
  • Loading branch information
srenatus committed Nov 2, 2022
1 parent 94f8bc7 commit f477e7f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
15 changes: 12 additions & 3 deletions docs/website/layouts/partials/docs/article.html
@@ -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
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
1 change: 1 addition & 0 deletions netlify.toml
Expand Up @@ -17,6 +17,7 @@ command = "make netlify-preview WASM_ENABLED=0 CGO_ENABLED=0"
# "netlify dev" will serve the static content using netlify locally
# with all the redirects and other netlify specific rules in place.
publish = "docs/website/public"
framework = "#static"

# To run the netlify dev service with hugo dev server "live" behind
# it uncomment these lines:
Expand Down

0 comments on commit f477e7f

Please sign in to comment.