Created
October 20, 2014 21:37
-
-
Save adamculpepper/49d3e59984064d7d6c0d to your computer and use it in GitHub Desktop.
Split Up URL slugs, add as body classes
This file contains hidden or 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
var loc = window.location; | |
var url = (location.href); | |
loc.origin || (loc.origin = loc.protocol + '//' + loc.host); | |
url = url.split('?')[0]; | |
var slugs = $.trim((url.replace(loc.origin, '')).split("/").join(" ")); | |
if (slugs == "") { | |
slugs = "home"; | |
} | |
$("body").addClass(slugs); //no touchy! | |
console.log(urlPieces); //remove |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment