-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use custom redirect template in jekyll-redirect-from plugin
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{% include head.html %} | ||
<body> | ||
<div class=""> | ||
{% include menu.html %} | ||
{{ content }} | ||
{% include footer.html %} | ||
</div> | ||
</body> | ||
</html> | ||
<script type="text/javascript"> | ||
function getBrowserLanguage() { | ||
try { | ||
return (navigator.browserLanguage || navigator.language || navigator.userLanguage).substr(0,2) | ||
} | ||
catch(e) { | ||
return undefined; | ||
} | ||
} | ||
// Redirect to the given redirect.to URL. If failed, redirect to the landing page upon browser language. | ||
// https://github.com/jekyll/jekyll-redirect-from#customizing-the-redirect-template | ||
if ("{{ page.redirect.to }}" != ""){ | ||
window.location.replace("{{ page.redirect.to }}" + window.location.hash + window.location.search); | ||
} | ||
else if (getBrowserLanguage().indexOf("ja") != -1) { | ||
window.location.replace("/ja"); | ||
} | ||
else { | ||
window.location.replace("/en"); | ||
} | ||
</script> |