Skip to content

Instantly share code, notes, and snippets.

@Fishrock123
Created November 8, 2013 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fishrock123/7379206 to your computer and use it in GitHub Desktop.
Save Fishrock123/7379206 to your computer and use it in GitHub Desktop.
My site's header highlighting code.
// Ignore the preceding '/'.
page = [removed].pathname.slice(1);
// The landing page corresponds to the 'home' icon.
if (page === '') page = 'home';
// Test if the page is a nav link.
page = page.match(/home|about|projects|blog/);
// Check the result of the regex.
if (page && page.length > 0) {
// Style the corresponding nav link.
$('#' + page[0]).children().addClass('current-page');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment