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 1845764281
commit 7bac2479ad
3 changed files with 52 additions and 22 deletions

View File

@ -1,30 +1,12 @@
---
title: Supported Versions of the Kubernetes Documentation
content_type: concept
title: Available Documentation Versions
content_type: custom
layout: supported-versions
card:
name: about
weight: 10
title: Supported Versions of the Documentation
title: Available Documentation Versions
---
<!-- overview -->
This website contains documentation for the current version of Kubernetes
and the four previous versions of Kubernetes.
<!-- body -->
## Current version
The current version is
[{{< param "version" >}}](/).
## Previous versions
{{< versions-other >}}

View File

@ -54,6 +54,15 @@ other = "I AM..."
[docs_label_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]
other = "Examples"

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 }}