From e1c803e57eb0bcf08c73ec6f65ff3fef313d3a70 Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Thu, 6 May 2021 17:09:59 +0200 Subject: [PATCH] website: resolve "latest" to latest version in shortcodes (#3436) This came up in the discussion of #3426. Note that there's two ways to access the current "latest" version: https://www.openpolicyagent.org/docs/latest/http-api-authorization/ https://www.openpolicyagent.org/docs/v0.28.0/http-api-authorization/ For both sites, the shortcodes now resolve to "0.28.0". Before, the first one would show "latest", the second "0.28.0". Signed-off-by: Stephan Renatus --- .../layouts/shortcodes/current_docker_version.html | 8 +++++--- docs/website/layouts/shortcodes/current_version.html | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/website/layouts/shortcodes/current_docker_version.html b/docs/website/layouts/shortcodes/current_docker_version.html index 9a9e7113a6..06c1df15c5 100644 --- a/docs/website/layouts/shortcodes/current_docker_version.html +++ b/docs/website/layouts/shortcodes/current_docker_version.html @@ -1,6 +1,8 @@ {{- $version := index (split $.Page.File.Path "/") 1 -}} -{{- if or (eq $version "edge") (eq $version "latest") -}} -{{ $version }} +{{- if eq $version "latest" -}} +{{- strings.TrimPrefix "v" (index site.Data.releases 1) -}} +{{- else if eq $version "edge" -}} +edge {{- else -}} {{- strings.TrimPrefix "v" $version -}} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/docs/website/layouts/shortcodes/current_version.html b/docs/website/layouts/shortcodes/current_version.html index 26bf2e2524..372607b677 100644 --- a/docs/website/layouts/shortcodes/current_version.html +++ b/docs/website/layouts/shortcodes/current_version.html @@ -1 +1,6 @@ -{{ index (split $.Page.File.Path "/") 1 }} \ No newline at end of file +{{- $version := index (split $.Page.File.Path "/") 1 -}} +{{- if (eq $version "latest") -}} +{{- index site.Data.releases 1 -}} +{{- else -}} +{{- $version -}} +{{- end -}} \ No newline at end of file