From 70a67c5f65d5eee83819e734232c5674ef3558bc Mon Sep 17 00:00:00 2001 From: PaarthAgarwal Date: Mon, 13 Feb 2023 17:21:59 +0530 Subject: [PATCH 01/11] fixed redirection logic Signed-off-by: PaarthAgarwal --- layouts/index.redirects | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/layouts/index.redirects b/layouts/index.redirects index 5d56313ca..1c949b6f3 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -1,4 +1,4 @@ {{- $harborLatest := (index site.Params.versions 0).harborversion -}} -/docs /docs/{{ $harborLatest }} 301! -/docs/latest /docs/{{ $harborLatest }} -/docs/latest/* /docs/{{ $harborLatest }}/:splat +/docs /docs/{{ $harborLatest }}/ 302! +/docs/latest /docs/{{ $harborLatest }}/ +/docs/latest/* /docs/{{ $harborLatest }}/:splat From 792a19ed06a3659f4a71e250306dae6b8ba082d8 Mon Sep 17 00:00:00 2001 From: PaarthAgarwal Date: Mon, 13 Feb 2023 17:35:06 +0530 Subject: [PATCH 02/11] update Signed-off-by: PaarthAgarwal --- layouts/index.redirects | 1 + 1 file changed, 1 insertion(+) diff --git a/layouts/index.redirects b/layouts/index.redirects index 1c949b6f3..c1ac4a718 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -1,4 +1,5 @@ {{- $harborLatest := (index site.Params.versions 0).harborversion -}} /docs /docs/{{ $harborLatest }}/ 302! +/docs/{.+} /docs/{{ $harborLatest }}/{.+} 302! /docs/latest /docs/{{ $harborLatest }}/ /docs/latest/* /docs/{{ $harborLatest }}/:splat From e629da88ef81f57b39251c9c619e6d26f85efd7a Mon Sep 17 00:00:00 2001 From: PaarthAgarwal Date: Mon, 13 Feb 2023 17:43:49 +0530 Subject: [PATCH 03/11] update Signed-off-by: PaarthAgarwal --- layouts/index.redirects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/index.redirects b/layouts/index.redirects index c1ac4a718..71534741f 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -1,5 +1,5 @@ {{- $harborLatest := (index site.Params.versions 0).harborversion -}} -/docs /docs/{{ $harborLatest }}/ 302! /docs/{.+} /docs/{{ $harborLatest }}/{.+} 302! /docs/latest /docs/{{ $harborLatest }}/ /docs/latest/* /docs/{{ $harborLatest }}/:splat +/docs/{.+} /docs/{{ $harborLatest }}/{.+} 302! \ No newline at end of file From c56174cb333175b3ff6293806f930ac8c2fb4b8c Mon Sep 17 00:00:00 2001 From: PaarthAgarwal Date: Mon, 13 Feb 2023 17:54:32 +0530 Subject: [PATCH 04/11] update Signed-off-by: PaarthAgarwal --- layouts/index.redirects | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/layouts/index.redirects b/layouts/index.redirects index 71534741f..d21cd2107 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -1,5 +1,4 @@ {{- $harborLatest := (index site.Params.versions 0).harborversion -}} -/docs/{.+} /docs/{{ $harborLatest }}/{.+} 302! +/docs/:splat /docs/{{ $harborLatest }}/:splat 302! /docs/latest /docs/{{ $harborLatest }}/ /docs/latest/* /docs/{{ $harborLatest }}/:splat -/docs/{.+} /docs/{{ $harborLatest }}/{.+} 302! \ No newline at end of file From 3f12b26e50d478405c35c796d891ba24b01cad30 Mon Sep 17 00:00:00 2001 From: PaarthAgarwal Date: Mon, 13 Feb 2023 19:24:00 +0530 Subject: [PATCH 05/11] update Signed-off-by: PaarthAgarwal --- layouts/index.redirects | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/layouts/index.redirects b/layouts/index.redirects index d21cd2107..7e50bcb28 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -1,4 +1,10 @@ -{{- $harborLatest := (index site.Params.versions 0).harborversion -}} -/docs/:splat /docs/{{ $harborLatest }}/:splat 302! +{{ $versions := site.Params.versions }} +{{ $latest := (index $versions 0).harborversion }} +{{ range $versions }} + {{ if eq .harborversion $1 }} + /docs/{{ .harborversion }}/{{ $2 }} /docs/{{ .harborversion }}/{{ $2 }} 200! + {{ end }} +{{ end }} +/docs/{{ $1 }}/{{ $2 }} /docs/{{ $latest }}/{{ $2 }} 301! /docs/latest /docs/{{ $harborLatest }}/ /docs/latest/* /docs/{{ $harborLatest }}/:splat From 70b878cc543d646d807456e840e2ebc963833503 Mon Sep 17 00:00:00 2001 From: PaarthAgarwal Date: Mon, 13 Feb 2023 19:43:52 +0530 Subject: [PATCH 06/11] update Signed-off-by: PaarthAgarwal --- layouts/index.redirects | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/index.redirects b/layouts/index.redirects index 7e50bcb28..32757ac17 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -1,10 +1,10 @@ {{ $versions := site.Params.versions }} -{{ $latest := (index $versions 0).harborversion }} +{{ $harborLatest := (index site.Params.versions 0).harborversion }} {{ range $versions }} {{ if eq .harborversion $1 }} /docs/{{ .harborversion }}/{{ $2 }} /docs/{{ .harborversion }}/{{ $2 }} 200! {{ end }} {{ end }} -/docs/{{ $1 }}/{{ $2 }} /docs/{{ $latest }}/{{ $2 }} 301! +/docs/{{ $1 }}/{{ $2 }} /docs/{{ $harborLatest }}/{{ $2 }} 301! /docs/latest /docs/{{ $harborLatest }}/ /docs/latest/* /docs/{{ $harborLatest }}/:splat From eb881109ecd81b526e4af4184f67b4eec7de081d Mon Sep 17 00:00:00 2001 From: PaarthAgarwal Date: Mon, 13 Feb 2023 19:54:01 +0530 Subject: [PATCH 07/11] update Signed-off-by: PaarthAgarwal --- layouts/index.redirects | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/layouts/index.redirects b/layouts/index.redirects index 32757ac17..9375f5756 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -1,5 +1,7 @@ -{{ $versions := site.Params.versions }} +{{ $versions := index site.Params.versions }} {{ $harborLatest := (index site.Params.versions 0).harborversion }} +{{ $1 := (split (substr .URL 0 -1) "/")[2] }} +{{ $2 := (split (substr .URL 0 -1) "/")[3] }} {{ range $versions }} {{ if eq .harborversion $1 }} /docs/{{ .harborversion }}/{{ $2 }} /docs/{{ .harborversion }}/{{ $2 }} 200! From e6084581a12b491ac27c5886848f31bcb5402677 Mon Sep 17 00:00:00 2001 From: PaarthAgarwal Date: Mon, 13 Feb 2023 19:57:13 +0530 Subject: [PATCH 08/11] update Signed-off-by: PaarthAgarwal --- layouts/index.redirects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/index.redirects b/layouts/index.redirects index 9375f5756..a0642d6b9 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -1,4 +1,4 @@ -{{ $versions := index site.Params.versions }} +{{ $versions := site.Params.versions }} {{ $harborLatest := (index site.Params.versions 0).harborversion }} {{ $1 := (split (substr .URL 0 -1) "/")[2] }} {{ $2 := (split (substr .URL 0 -1) "/")[3] }} From 0b67803eb59ca911d2fb2aa879e70193d883942c Mon Sep 17 00:00:00 2001 From: PaarthAgarwal Date: Mon, 13 Feb 2023 20:06:00 +0530 Subject: [PATCH 09/11] test Signed-off-by: PaarthAgarwal --- layouts/index.redirects | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/layouts/index.redirects b/layouts/index.redirects index a0642d6b9..d1932ccfe 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -1,12 +1,19 @@ -{{ $versions := site.Params.versions }} +{{ $versions := (slice "1.10" "2.0.0" "2.1.0" "2.2.0" "2.3.0" "2.4.0" "2.5.0" "2.6.0" "2.7.0") }} {{ $harborLatest := (index site.Params.versions 0).harborversion }} -{{ $1 := (split (substr .URL 0 -1) "/")[2] }} -{{ $2 := (split (substr .URL 0 -1) "/")[3] }} + +{{ $requestedVersion := (reReplace "(^/docs/)([^/]+)(.*)", "$2", .URL.Path) }} +{{ $redirect := false }} {{ range $versions }} - {{ if eq .harborversion $1 }} - /docs/{{ .harborversion }}/{{ $2 }} /docs/{{ .harborversion }}/{{ $2 }} 200! - {{ end }} +{{ if eq $requestedVersion . }} +{{ $redirect = false }} +{{ break }} +{{ else }} +{{ $redirect = true }} +{{ end }} +{{ end }} + +{{ if $redirect }} +/docs/:splat /docs/{{ $harborLatest }}/:splat 302! {{ end }} -/docs/{{ $1 }}/{{ $2 }} /docs/{{ $harborLatest }}/{{ $2 }} 301! /docs/latest /docs/{{ $harborLatest }}/ /docs/latest/* /docs/{{ $harborLatest }}/:splat From 662eb5dc58c7347f66865e66f24401b5131c402a Mon Sep 17 00:00:00 2001 From: PaarthAgarwal Date: Mon, 13 Feb 2023 23:11:05 +0530 Subject: [PATCH 10/11] update Signed-off-by: PaarthAgarwal --- layouts/index.redirects | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/layouts/index.redirects b/layouts/index.redirects index d1932ccfe..7d6a9a45d 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -1,19 +1,15 @@ -{{ $versions := (slice "1.10" "2.0.0" "2.1.0" "2.2.0" "2.3.0" "2.4.0" "2.5.0" "2.6.0" "2.7.0") }} {{ $harborLatest := (index site.Params.versions 0).harborversion }} -{{ $requestedVersion := (reReplace "(^/docs/)([^/]+)(.*)", "$2", .URL.Path) }} -{{ $redirect := false }} -{{ range $versions }} -{{ if eq $requestedVersion . }} -{{ $redirect = false }} -{{ break }} -{{ else }} -{{ $redirect = true }} -{{ end }} -{{ end }} +/docs/2.7.0/ /docs/2.7.0/ +/docs/2.6.0/ /docs/2.6.0/ +/docs/2.5.0/ /docs/2.5.0/ +/docs/2.4.0/ /docs/2.4.0/ +/docs/2.3.0/ /docs/2.3.0/ +/docs/2.2.0/ /docs/2.2.0/ +/docs/2.1.0/ /docs/2.1.0/ +/docs/2.0.0/ /docs/2.0.0/ +/docs/1.10/ /docs/1.10/ -{{ if $redirect }} /docs/:splat /docs/{{ $harborLatest }}/:splat 302! -{{ end }} /docs/latest /docs/{{ $harborLatest }}/ /docs/latest/* /docs/{{ $harborLatest }}/:splat From 05080e9943c1202d1cd3372be2e312d02d744c51 Mon Sep 17 00:00:00 2001 From: PaarthAgarwal Date: Mon, 13 Feb 2023 23:18:11 +0530 Subject: [PATCH 11/11] fixed redirection logic Signed-off-by: PaarthAgarwal --- layouts/index.redirects | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/layouts/index.redirects b/layouts/index.redirects index 5d56313ca..7d6a9a45d 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -1,4 +1,15 @@ -{{- $harborLatest := (index site.Params.versions 0).harborversion -}} -/docs /docs/{{ $harborLatest }} 301! -/docs/latest /docs/{{ $harborLatest }} -/docs/latest/* /docs/{{ $harborLatest }}/:splat +{{ $harborLatest := (index site.Params.versions 0).harborversion }} + +/docs/2.7.0/ /docs/2.7.0/ +/docs/2.6.0/ /docs/2.6.0/ +/docs/2.5.0/ /docs/2.5.0/ +/docs/2.4.0/ /docs/2.4.0/ +/docs/2.3.0/ /docs/2.3.0/ +/docs/2.2.0/ /docs/2.2.0/ +/docs/2.1.0/ /docs/2.1.0/ +/docs/2.0.0/ /docs/2.0.0/ +/docs/1.10/ /docs/1.10/ + +/docs/:splat /docs/{{ $harborLatest }}/:splat 302! +/docs/latest /docs/{{ $harborLatest }}/ +/docs/latest/* /docs/{{ $harborLatest }}/:splat