diff --git a/content/ja/docs/specs.md b/content/ja/docs/specs.md new file mode 100644 index 000000000000..0bf9f5335bbd --- /dev/null +++ b/content/ja/docs/specs.md @@ -0,0 +1,11 @@ +--- +title: Specifications +linkTitle: Specs ↗ +description: _Redirect page_ +weight: 960 +# _build: { render: link } +redirect: /docs/specs # TODO: this will need to be /en/... +redirects: [{ from: '*', to: ':splat' }] +--- + +Netlify redirect target: [{{% param "title" %}}]({{% param "redirect" %}}). diff --git a/layouts/index.redirects b/layouts/index.redirects index 280f6762074b..7e7f4ac8073a 100644 --- a/layouts/index.redirects +++ b/layouts/index.redirects @@ -72,3 +72,7 @@ {{ end }} {{ return $result }} {{ end }} + +{{/* Multilingual support */ -}} + +{{ partial "redirects/sites.redirects" . | partial "func/trim-lines.html" -}} diff --git a/layouts/partials/func/trim-lines.html b/layouts/partials/func/trim-lines.html new file mode 100644 index 000000000000..db3b92212962 --- /dev/null +++ b/layouts/partials/func/trim-lines.html @@ -0,0 +1,3 @@ +{{ range split . "\n" -}} +{{ trim . " \t" }} +{{ end -}} diff --git a/layouts/partials/redirects/sites.redirects b/layouts/partials/redirects/sites.redirects new file mode 100644 index 000000000000..9240260dfaf7 --- /dev/null +++ b/layouts/partials/redirects/sites.redirects @@ -0,0 +1,39 @@ +{{/* Redirect for default language when .LanguagePrefix is empty. */ -}} + +{{ $defaultLang := "" -}} +{{ with .Site.Sites.Default -}} + {{ if eq .LanguagePrefix "" -}} + {{ with .Language.Lang -}} + {{ $defaultLang = . -}} + /{{ . }} / + /{{ . }}/* /:splat + {{ end -}} + {{ end -}} +{{ end -}} + +{{/* Process non-default languages. */ -}} + +{{ range after 1 .Sites -}} + + {{ $siteLang := .Language.Lang -}} + + # Site localization {{ $siteLang }} + {{ range $p := .Pages -}} + + {{ range $p.Params.redirects -}} + {{ $fallbackPage := partial "i18n/fallback-page.html" $p -}} + {{ if or (eq $siteLang $defaultLang) (not $fallbackPage) -}} + {{ $from := cond (strings.HasPrefix .from "/") + .from + (print $p.RelPermalink .from) -}} + {{ $to := cond (strings.HasPrefix .to "/") + .to + (print $p.RelPermalink .to) -}} + {{ $from | printf "%-35s" }} {{ $to }} + {{ else -}} + {{/* # {{ $p.RelPermalink }} */ -}} + {{ end -}} + {{ end -}} + {{ end -}} + +{{ end -}}