-
Notifications
You must be signed in to change notification settings - Fork 1
/
404.html
33 lines (30 loc) · 1.03 KB
/
404.html
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
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
const current_url = window.location.origin + window.location.pathname;
const paths = current_url.split('/');
const pattern = /^(zh-CN|zh-TW|en-US|fr-FR)$/;
const lang_index = paths.findIndex(path => pattern.test(path));
if (lang_index !== -1) {
const lang = paths[lang_index];
if (lang === 'zh-CN') {
window.location.href = paths.slice(0, 4).join('/') + '/unavailable.html';
} else {
const new_paths = paths.slice(0, lang_index).concat(
lang === 'en-US' || lang === 'zh-TW' ? 'zh-CN' : 'en-US'
).concat(paths.slice(lang_index + 1));
window.location.href = new_paths.join('/').replace(/\.md$/, '.html');
}
} else {
window.location.href = paths.slice(0, 4).join('/') + '/unavailable.html';
}
</script>
</head>
<body>
<h2>404</h2>
</body>
</html>