docs: improve latest-version banner
Make the latest-version banner sticky and more noticeable, and ensure the link to the latest version links to the current document if possible. Signed-off-by: Tim Jones <tim.jones@siderolabs.com>
This commit is contained in:
parent
23984efcdf
commit
0fe4a7832b
5
website/assets/scss/_styles_project.scss
Normal file
5
website/assets/scss/_styles_project.scss
Normal file
@ -0,0 +1,5 @@
|
||||
.version-banner {
|
||||
position: sticky;
|
||||
top: 5rem;
|
||||
z-index: 1;
|
||||
}
|
10
website/layouts/partials/doc_latest_version.html
Normal file
10
website/layouts/partials/doc_latest_version.html
Normal file
@ -0,0 +1,10 @@
|
||||
{{ $page := .Site.Params.url_latest_version }}
|
||||
{{ $doc_latest_version := replaceRE (.Section | printf "^/%s") .Site.Params.url_latest_version .Page.RelPermalink | path.Clean }}
|
||||
{{ range $p := (where .Site.Pages "Section" (.Site.Params.url_latest_version | strings.TrimPrefix "/")) }}
|
||||
{{ $page = cond (eq $doc_latest_version ($p.RelPermalink | path.Clean)) $p.RelPermalink $page }}
|
||||
{{ range .Aliases }}
|
||||
{{ $alias := cond (hasPrefix . "/") . (path.Join $p.RelPermalink ".." .) }}
|
||||
{{ $page = cond (eq $alias $doc_latest_version) $p.RelPermalink $page}}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ return $page }}
|
28
website/layouts/partials/version-banner.html
Normal file
28
website/layouts/partials/version-banner.html
Normal file
@ -0,0 +1,28 @@
|
||||
<!-- Check the variable that indicates whether this is an archived doc set.
|
||||
If yes, display a banner. -->
|
||||
{{ $latest_version := .Site.Params.url_latest_version }}
|
||||
{{ $current_version := .Section | printf "/%s" }}
|
||||
{{ $latest_doc := partial "doc_latest_version.html" . }}
|
||||
|
||||
{{ if .FirstSection.Params.prerelease }}
|
||||
{{ $color := "info" }}
|
||||
<div class="version-banner pageinfo pageinfo-{{ $color }}">
|
||||
{{ with $current_version }}<p>Version {{ trim . "/" | markdownify }} of the
|
||||
documentation is for the Talos version being developed.
|
||||
{{ with $latest_version }}For the latest stable version of Talos, see the
|
||||
<a href="{{ $latest_doc | safeURL }}">latest version</a>.</p>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ else if ne $latest_version $current_version }}
|
||||
{{ $color := "warning" }}
|
||||
<div class="version-banner pageinfo pageinfo-{{ $color }}">
|
||||
{{ with $current_version }}<p>Version {{ trim . "/" | markdownify }} of the
|
||||
documentation is no longer actively maintained. The site that you are
|
||||
currently viewing is an archived snapshot.
|
||||
{{ with $latest_version }}For up-to-date documentation, see the
|
||||
<a href="{{ $latest_doc | safeURL }}">latest version</a>.</p>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
Loading…
Reference in New Issue
Block a user