Skip to content

Instantly share code, notes, and snippets.

@adamculpepper
Created October 20, 2014 21:37
Show Gist options
  • Save adamculpepper/49d3e59984064d7d6c0d to your computer and use it in GitHub Desktop.
Save adamculpepper/49d3e59984064d7d6c0d to your computer and use it in GitHub Desktop.
Split Up URL slugs, add as body classes
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