Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed redirection logic #419

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
update
Signed-off-by: PaarthAgarwal <paarth.agarwal.mec20@itbhu.ac.in>
PaarthAgarwal committed Feb 13, 2023
commit 662eb5dc58c7347f66865e66f24401b5131c402a
22 changes: 9 additions & 13 deletions layouts/index.redirects
Original file line number Diff line number Diff line change
@@ -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