From c8d46c99b61c9d8d83925abb3040f8e913e24fe5 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Sat, 2 Nov 2024 23:37:55 -0400 Subject: [PATCH] Add support for v2 docs in the navigation (#765) ## Which problem is this PR solving? - Part of #731 ## Description of the changes - Add new V2 variables to config - Change the display of the current / latest version on the doc pages to allow switching between 1.x and 2.x - Update Versions navbar dropdown to include 2.x versions (currently disabled until we actually have 2.0) ## How was this change tested? - Locally --------- Signed-off-by: Yuri Shkuro --- config.toml | 6 ++- .../layouts/partials/docs/header.html | 50 ++++++++++++++----- .../jaeger-docs/layouts/partials/navbar.html | 34 +++++++++---- 3 files changed, 66 insertions(+), 24 deletions(-) diff --git a/config.toml b/config.toml index 62054353..9342a0c2 100644 --- a/config.toml +++ b/config.toml @@ -27,7 +27,11 @@ home = [ "HTML", "JSON", "REDIRECTS" ] latest = "1.62" binariesLatest = "1.62.0" - versions = ["1.62","1.61","1.60","1.59","1.58","1.57","1.56","1.55","1.54","1.53","1.52","1.51","1.50","1.49","1.48","1.47","1.46","1.45","1.44","1.43","1.42","1.41","1.40","1.39","1.38","1.37","1.36","1.35","1.34","1.33","1.32"] + versions = ["1.62","1.61","1.60","1.59","1.58","1.57","1.56","1.55","1.54","1.53","1.52"] + + latestV2 = "next-release-v2" + binariesLatestV2 = "2.0.0-rc2" + versionsV2 = [] [navbar] [[links]] diff --git a/themes/jaeger-docs/layouts/partials/docs/header.html b/themes/jaeger-docs/layouts/partials/docs/header.html index 6cd35165..abe7a8a2 100644 --- a/themes/jaeger-docs/layouts/partials/docs/header.html +++ b/themes/jaeger-docs/layouts/partials/docs/header.html @@ -1,15 +1,33 @@ -{{ $versions := site.Params.versions }} -{{ $latest := site.Params.latest }} -{{ $path := "" }} +{{ $path := "" }} {{ with .File }} {{ $path = .Path }} {{ else }} {{ $path = .Path }} {{ end }} +{{ $latestV1 := site.Params.latest }} +{{ $latestV2 := site.Params.latestV2 }} {{ $version := index (split $path "/") 1 }} -{{ $isLatest := eq $version $latest }} -{{ $isNextRelease := eq $version "next-release" }} -{{ $latestUrl := .RelPermalink | replaceRE $version $latest }} +{{ $vMajor := index (split $version ".") 0 }} +{{ $isNextRelease := false }} +{{ if eq $version "next-release" }} + {{ $vMajor = "1" }} + {{ $isNextRelease = true }} +{{ else if eq $version "next-release-v2" }} + {{ $vMajor = "2" }} + {{ $isNextRelease = true }} +{{ end }} + +{{ $isLatest := or (eq $version $latestV1) (eq $version $latestV2) }} +{{ $latestUrlV1 := .RelPermalink | replaceRE $version $latestV1 }} +{{ $latestUrlV2 := .RelPermalink | replaceRE $version $latestV2 }} + +{{ $latestUrl := "" }} +{{ if eq $vMajor "1" }} + {{ $latestUrl = .RelPermalink | replaceRE $version $latestV1 }} +{{ else if eq $vMajor "2" }} + {{ $latestUrl = .RelPermalink | replaceRE $version $latestV2 }} +{{ end }} +

{{ .Title }}

{{ with .Params.description }} @@ -21,18 +39,26 @@ Version  {{ $version }} + {{ if $isNextRelease }} + Preview + {{ end }} {{ if $isLatest }} Latest - {{ else if $isNextRelease }} - - Preview - {{ else }} - Click here for the latest version + Go to the latest {{ $vMajor }}.x version + + {{ end }} + {{ if eq $vMajor "1" }} + + Go to the latest 2.x version + + {{ else if eq $vMajor "2" }} + + Go to the latest 1.x version {{ end }} - + {{ end }}
diff --git a/themes/jaeger-docs/layouts/partials/navbar.html b/themes/jaeger-docs/layouts/partials/navbar.html index 6bd001d1..e3c8bd33 100644 --- a/themes/jaeger-docs/layouts/partials/navbar.html +++ b/themes/jaeger-docs/layouts/partials/navbar.html @@ -1,12 +1,14 @@ {{ $menuPages := site.Menus.docs }} {{ $githubRepo := site.Params.githubrepo }} {{ $twitterHandle := site.Params.twitterhandle }} -{{ $versions := site.Params.versions }} -{{ $latest := site.Params.latest }} +{{ $versionsV1 := site.Params.versions }} +{{ $versionsV2 := site.Params.versionsV2 }} +{{ $versions := append $versionsV1 $versionsV2 }} +{{ $latestV1 := site.Params.latest }} +{{ $latestV2 := site.Params.latestV2 }} {{ $docs := where site.Pages "Section" "docs" }} {{ $isDocsPage := eq .Section "docs" }} -{{ $preview := getenv "HUGO_PREVIEW" }} -{{ $isPreview := eq $preview "true" }} +{{ $isPreview := eq (getenv "HUGO_PREVIEW") "true" }} {{ $path := "" }} {{ with .File }} {{ $path = .Path }} @@ -14,6 +16,13 @@ {{ $path = .Path }} {{ end }} {{ $majorMinorVersion := index (split $path "/") 1 }} +{{ $vMajor := index (split $majorMinorVersion ".") 0 }} +{{ if eq $majorMinorVersion "next-release" }} + {{ $vMajor = "1" }} +{{ else if eq $majorMinorVersion "next-release-v2" }} + {{ $vMajor = "2" }} + {{ end }} +{{ $isLatest := or (eq $majorMinorVersion $latestV1) (eq $majorMinorVersion $latestV2) }}