A way to enable custom 404 for Tumblr. Well, it 'kinda' works
<script type="text/javascript"> | |
/* Works for me */ | |
var text_posts = document.getElementsByClassName("regular"); | |
var text_404 = "The URL you requested could not be found."; | |
var title_404 = "Not Found"; | |
if(text_posts.length == 1){ | |
var bodyNode = text_posts[0].lastChild; | |
if(bodyNode.previousSibling.textContent == text_404) { | |
// titleNode.innerHTML = "<a href='/'>Not Found</a>"; | |
var blog_loc = "http://" + document.domain + "/"; | |
var query = window.location.href.slice(blog_loc.length); | |
var tokens = query.toLowerCase().split('/'); | |
var keyword = tokens.join(" "); | |
var bodyContent = "Looks like you came from an old bookmark, or just looking for a page that doesn't exist. Were you looking for <span class='tg'><a href='/search/"+ escape(keyword) +"'>"+keyword+"</a></span>"; | |
bodyNode.previousSibling.innerHTML = bodyContent; | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment