Improve index.html: client-side redirect
This commit is contained in:
parent
a709ec0fea
commit
c252785070
52
index.html
52
index.html
@ -4,33 +4,33 @@ layout: none
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Redirecting...</title>
|
||||
<title>Minetest Modding Book</title>
|
||||
<meta name="description" content="An easy guide to learn how to create mods for Minetest">
|
||||
<script>
|
||||
var languages = {{ site.data.languages | jsonify }};
|
||||
function getLanguage() {
|
||||
var userLang = navigator.language || navigator.userLanguage;
|
||||
for (var i = 0; i < languages.length; i++) {
|
||||
var lang = languages[i];
|
||||
if (userLang.indexOf(lang.code) == 0) {
|
||||
return lang;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
var language = getLanguage() || languages[0];
|
||||
window.location.replace(language.code + "/index.html");
|
||||
</script>
|
||||
<meta http-equiv="refresh" content="0;URL='{{ 'en/index.html' | absolute_url }}'" />
|
||||
</head>
|
||||
<body>
|
||||
Detecting and redirecting to the correct translation.<br><br>
|
||||
|
||||
<a href="en/index.html">View English Translation</a><br><br>
|
||||
|
||||
<script>
|
||||
var languages = {{ site.data.languages | jsonify }};
|
||||
function getLanguage() {
|
||||
var userLang = navigator.language || navigator.userLanguage;
|
||||
for (var i = 0; i < languages.length; i++) {
|
||||
var lang = languages[i];
|
||||
if (userLang.indexOf(lang.code) == 0) {
|
||||
return lang;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
var language = getLanguage() || languages[0];
|
||||
var url = language.code + "/index.html";
|
||||
document.write('<a href="' + language.code +
|
||||
'/index.html">Redirecting to the ' + language.name +
|
||||
' version...</a>');
|
||||
|
||||
window.location.replace(url);
|
||||
</script>
|
||||
<main>
|
||||
<h1>Minetest Modding Book</h1>
|
||||
<p>Detecting and redirecting to the correct translation.</p>
|
||||
<p>
|
||||
<a href="en/index.html">View English Translation</a>
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user