{{- $latest       := index site.Data.releases 1 -}}
{{- $allDocs      := where site.RegularPages "Section" "docs" }}
{{- $docRedirects := site.Data.redirects }}

# Redirect to latest doc version by default
/docs     /docs/latest      301!

# v0.14.0 re-org redirects
# TODO: Remove at some point in the future when its more ok to break old links en-mass
/docs/latest/get-started                            /docs/latest/                           301!
/docs/latest/how-does-opa-work/                     /docs/latest/#how-does-opa-work         301!
/docs/latest/how-do-i-write-policies/               /docs/latest/policy-language/           301!
/docs/latest/how-do-i-test-policies/                /docs/latest/policy-testing/            301!
/docs/latest/language-reference/                    /docs/latest/policy-reference/          301!
/docs/latest/language-cheatsheet/                   /docs/latest/edge/policy-cheatsheet/    301!
/docs/latest/bundles/                               /docs/latest/management/#bundles        301!
/docs/latest/status/                                /docs/latest/management/#status         301!
/docs/latest/decision-logs/                         /docs/latest/management/#decision-logs  301!
/docs/latest/discovery/                             /docs/latest/management/#discovery      301!
/docs/latest/kubernetes-admission-control/          /docs/latest/kubernetes-tutorial/       301!

{{- range $docRedirects }}
/docs/{{ . }}     /docs/latest/{{ . }}      301!

# Legacy git book redirects
/docs/{{ . }}.html /docs/latest/{{ . }}     301!
{{- end }}

# Download URLs
/downloads/edge/*       https://opa-releases.s3.amazonaws.com/edge/:splat 200
/downloads/latest/*     https://github.com/open-policy-agent/opa/releases/download/{{ $latest }}/:splat 200
/downloads/*            https://github.com/open-policy-agent/opa/releases/download/:splat 200
