forked from yarnpkg/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_redirects
67 lines (55 loc) · 3.27 KB
/
_redirects
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
layout: null
---
/:lang/packages/ /lang/:lang/packages 200
/:lang/package/* /lang/:lang/package 200
/downloads/:version/:file https://github.com/yarnpkg/yarn/releases/download/v:version/:file
# Nice short URLs to download the latest release
/latest.tar.gz https://github.com/yarnpkg/yarn/releases/download/v{{site.latest_version}}/yarn-v{{site.latest_version}}.tar.gz 302
/latest.tar.gz.asc https://github.com/yarnpkg/yarn/releases/download/v{{site.latest_version}}/yarn-v{{site.latest_version}}.tar.gz.asc 302
/latest.msi https://github.com/yarnpkg/yarn/releases/download/v{{site.latest_version}}/yarn-{{site.latest_version}}.msi 302
/latest.deb https://github.com/yarnpkg/yarn/releases/download/v{{site.latest_version}}/yarn_{{site.latest_version}}_all.deb 302
/latest.rpm https://github.com/yarnpkg/yarn/releases/download/v{{site.latest_version}}/yarn-{{site.latest_version}}-1.noarch.rpm 302
# Nice short URLs for latest RC
# If Netlify supported regular expressions in their rewrite rules, these could
# simply be a part of the rules above. Alas, they don't support it :(
/latest-rc.tar.gz https://github.com/yarnpkg/yarn/releases/download/v{{site.latest_rc_version}}/yarn-v{{site.latest_rc_version}}.tar.gz 302
/latest-rc.tar.gz.asc https://github.com/yarnpkg/yarn/releases/download/v{{site.latest_rc_version}}/yarn-v{{site.latest_rc_version}}.tar.gz.asc 302
/latest-rc.msi https://github.com/yarnpkg/yarn/releases/download/v{{site.latest_rc_version}}/yarn-{{site.latest_rc_version}}.msi 302
/latest-rc.deb https://github.com/yarnpkg/yarn/releases/download/v{{site.latest_rc_version}}/yarn_{{site.latest_rc_version}}_all.deb 302
/latest-rc.rpm https://github.com/yarnpkg/yarn/releases/download/v{{site.latest_rc_version}}/yarn-{{site.latest_rc_version}}-1.noarch.rpm 302
{% capture _redirects %}
{% assign urls_sorted = site.pages | map: "url" | sort %}
{% assign urls_filtered = "" | split: "," | pop %}
{% for url in urls_sorted %}
{% assign prefix = "/lang/en/" %}
{% assign prefix_size = prefix | size %}
{% assign prefix_chars = url | slice: 0, prefix_size %}
{% if prefix_chars == prefix %}
{% assign url_stripped = url | replace: prefix, "/" %}
{% assign urls_filtered = urls_filtered | push: url_stripped %}
{% endif %}
{% endfor %}
{% assign redirectsBase = "" | split: "," | pop %}
{% assign redirectsLang = "" | split: "," | pop %}
{% for url in urls_filtered %}
{% for language in site.data.languages %}
{% if language.enabled %}
{% for accept_language in language.accept_languages %}
{% capture redirect %}{{url}} /{{language.tag}}{{url}} 302 Language={{accept_language}}{% endcapture %}
{% assign redirectsBase = redirectsBase | push: redirect %}
{% endfor %}
{% capture redirect %}/{{language.tag}}{{url}} /lang/{{language.tag}}{{url}} 200{% endcapture %}
{% assign redirectsLang = redirectsLang | push: redirect %}
{% endif %}
{% endfor %}
{% endfor %}
{% capture newline %}
{% endcapture %}
{% endcapture %}
# With Language
{{redirectsLang | join: newline}}
# Without Language
{{redirectsBase | join: newline}}
# ls was renamed to list
/:language/docs/cli/ls /:language/docs/cli/list 301