mirror of
https://github.com/docker/docs.git
synced 2026-03-27 06:18:55 +07:00
41 lines
948 B
JSON
41 lines
948 B
JSON
{{- /*
|
|
|
|
This template generates the redirects.json file used to generate 301
|
|
redirects in production. It takes all the redirects defined in
|
|
data/redirects.yml, as well as all the aliases defined in front matter, and
|
|
outputs a simple key-value JSON file:
|
|
|
|
{
|
|
"<request-path>": "<redirect-path>",
|
|
...
|
|
}
|
|
|
|
e.g.
|
|
|
|
{
|
|
"/engine/reference/builder/": "/reference/dockerfile/",
|
|
...
|
|
}
|
|
|
|
*/
|
|
-}}
|
|
|
|
{{- $redirects := newScratch }}
|
|
{{- range hugo.Sites -}}
|
|
{{- range .Pages -}}
|
|
{{- if .Params.aliases -}}
|
|
{{- $target := .RelPermalink -}}
|
|
{{- range .Params.aliases -}}
|
|
{{ $redirects.SetInMap "paths" . $target }}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- range $target, $aliases := hugo.Data.redirects -}}
|
|
{{- range $aliases }}
|
|
{{- $redirects.SetInMap "paths" . $target -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- $opts := dict "noHTMLEscape" true }}
|
|
{{- $redirects.Get "paths" | jsonify $opts }}
|