Skip to content

Commit

Permalink
Create alias.html
Browse files Browse the repository at this point in the history
trying to fix issue Exodus-Privacy#200
  • Loading branch information
Ser-Bul authored May 24, 2024
1 parent 1105a17 commit 1507915
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions themes/hugo-bootstrap/layouts/alias.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!DOCTYPE html>
<html>
<head>
<title>{{ .Permalink }}</title>
<link rel="canonical" href="{{ .Permalink }}"/>
<meta name="robots" content="noindex">
<meta charset="utf-8"/>
<noscript>
<meta http-equiv="refresh" content="0; url={{ .Permalink }}"/>
</noscript>
<script>
;(function () {
// Only do i18n at root,
// otherwise, redirect immediately
if (window.location.pathname !== '/') {
window.location.replace('{{ .Permalink }}')
return
}

var getFirstBrowserLanguage = function () {
var nav = window.navigator,
browserLanguagePropertyKeys = ['language', 'browserLanguage', 'systemLanguage', 'userLanguage'],
i,
language

if (Array.isArray(nav.languages)) {
for (i = 0; i < nav.languages.length; i++) {
language = nav.languages[i]
if (language && language.length) {
return language
}
}
}

// support for other well known properties in browsers
for (i = 0; i < browserLanguagePropertyKeys.length; i++) {
language = nav[browserLanguagePropertyKeys[i]]
if (language && language.length) {
return language
}
}
return 'en'
}

var preferLang = getFirstBrowserLanguage()
if (preferLang.indexOf('fr') !== -1) {
// visitor prefers French
window.location.replace('/fr/')
} else if (preferLang.indexOf('ru') !== -1) {
// visitor prefers Russian
window.location.replace('/ru/')
} else {
// default to English
window.location.replace('/en/')
}
})()
</script>
</head>
<body>
<h1>Rerouting</h1>
<p>You should be rerouted in a jiff, if not, <a href="{{ .Permalink }}">click here</a>.</p>
</body>
</html>

0 comments on commit 1507915

Please sign in to comment.