Revise list of available documentation versions

For older releases, the previous rendering wasn't quite right.
Implement a custom layout for the supported versions list

This commit does NOT remove the shortcode named {{< versions-other >}}
because it is still used in some localizations.
This commit is contained in:
Tim Bannister
2020-08-28 13:47:18 +01:00
parent b4485527d8
commit b0469e6de0
3 changed files with 52 additions and 22 deletions
+4 -22
View File
@@ -1,30 +1,12 @@
--- ---
title: Supported Versions of the Kubernetes Documentation title: Available Documentation Versions
content_type: concept content_type: custom
layout: supported-versions
card: card:
name: about name: about
weight: 10 weight: 10
title: Supported Versions of the Documentation title: Available Documentation Versions
--- ---
<!-- overview -->
This website contains documentation for the current version of Kubernetes This website contains documentation for the current version of Kubernetes
and the four previous versions of Kubernetes. and the four previous versions of Kubernetes.
<!-- body -->
## Current version
The current version is
[{{< param "version" >}}](/).
## Previous versions
{{< versions-other >}}
+9
View File
@@ -54,6 +54,15 @@ other = "I AM..."
[docs_label_users] [docs_label_users]
other = "Users" other = "Users"
[docs_version_current]
other = "(this documentation)"
[docs_version_latest_heading]
other = "Latest version"
[docs_version_other_heading]
other = "Older versions"
[examples_heading] [examples_heading]
other = "Examples" other = "Examples"
+39
View File
@@ -0,0 +1,39 @@
{{ define "main" }}
<div class="td-content">
{{ partial "docs/content-page" (dict "ctx" . "page" .) }}
{{ $versions := .Page.Param "versions" }}
{{ $thisPageRelUri := .Page.RelPermalink }}
{{ $thisVersionArray := split (.Page.Param "version") "." }}
{{ $.Scratch.Set "version-class" (slice "placeholder") }}
{{/* "placeholder" is also used later to check whether we opened the <ul> */}}
{{ range $index, $version := $versions }}
{{ $.Scratch.Set "version-class" (slice "") }}
{{ $versionArray := split .version "." }}
{{ if eq $index 0 }}
<h2 id="version-latest">{{ T "docs_version_latest_heading" }}</h2>
<ul>
{{ $.Scratch.Set "version-class" ($.Scratch.Get "version-class" | append "version-latest" ) }}
{{ end }}
{{ if eq $index 1 }}
</ul>
<h2 id="versions-older">{{ T "docs_version_other_heading" }}</h2>
<ul>
{{ end }}
{{ if eq .version ( delimit $thisVersionArray "." ) }}
{{ $.Scratch.Set "version-class" ($.Scratch.Get "version-class" | append "version-current" ) }}
{{ end }}
<li class="{{ delimit ( $.Scratch.Get "version-class") " " }}">
<a href="{{ .url }}{{ $thisPageRelUri }}">{{ .version }}</a>
{{ if eq .version ( delimit $thisVersionArray "." ) }}
{{ T "docs_version_current" }}
{{ end }}
</li>
{{ end }}
{{ if ne (index ($.Scratch.Get "version-class") 0) "placeholder" }}
</ul>
{{ end }}
{{ end }}