Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically redirects if a page differing only in case is found.
- Loading branch information
Showing
2 changed files
with
35 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,34 @@ | ||
--- | ||
layout: page | ||
title: 404 Page Not Found | ||
--- | ||
<script> | ||
var allposts = []; | ||
function redirectToCorrectPage() { | ||
{% for post in site.pages %} | ||
allposts.push("{{ post.url }}"); | ||
{% endfor %} | ||
{% for post in site.wikis %} | ||
allposts.push("{{ post.url }}"); | ||
{% endfor %} | ||
var url = window.location.pathname; | ||
// strip trailing / | ||
if (url.slice(-1) === "/") { | ||
url = url.slice(0, -1); | ||
} | ||
var allpostsUpperCase = allposts.map(function(value) { | ||
// strip trailing / | ||
if (value.slice(-1) === "/") { | ||
value = value.slice(0, -1); | ||
} | ||
return value.toUpperCase(); | ||
}); | ||
var i = allpostsUpperCase.indexOf(url.toUpperCase()); | ||
if (i != -1) { | ||
console.log(allposts[i]); | ||
window.location = allposts[i]; | ||
} | ||
} | ||
window.onload = redirectToCorrectPage; | ||
</script> | ||
<p>Sorry this page does not exist =(</p> |
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 |
---|---|---|
|
@@ -83,3 +83,4 @@ defaults: | |
path: "" # empty string for all files | ||
values: | ||
layout: page | ||
|