forked from yarnpkg/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_redirects
86 lines (69 loc) · 4.28 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
layout: null
---
# Redirect from default Netlify subdomain
https://yarnpkg.netlify.com/* https://classic.yarnpkg.com/:splat 301!
# Redirect from "legacy" subdomain, as we renamed it to "classic".
https://legacy.yarnpkg.com/* https://classic.yarnpkg.com/:splat 301!
/: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
/latest.rpm https://github.com/yarnpkg/yarn/releases/download/v{{site.latest_version}}/yarn-{{site.latest_version}}-1.noarch.rpm 302
/latest.js https://github.com/yarnpkg/yarn/releases/download/v{{site.latest_version}}/yarn-{{site.latest_version}}.js 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
/latest-rc.js https://github.com/yarnpkg/yarn/releases/download/v{{site.latest_rc_version}}/yarn-{{site.latest_rc_version}}.js 302
# Comparison page to PNPM's benchmark repo
/compare https://github.com/pnpm/node-package-manager-benchmark 302
:lang/compare https://github.com/pnpm/node-package-manager-benchmark 302
lang/:lang/compare https://github.com/pnpm/node-package-manager-benchmark 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}}
# renamed commands
/:language/docs/cli/ls /:language/docs/cli/list 301
/:language/docs/cli/clean /:language/docs/cli/autoclean 301
# default to english
/* /en/:splat 302