Skip to content

Commit

Permalink
Add bold for selected nav
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle committed Aug 3, 2018
1 parent 6c2b90f commit ab89d59
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion docs/index.html
Expand Up @@ -57,6 +57,11 @@
font-size: 0.8em;
}

nav .selected {
color: #21283E;
font-weight: bold;
}

header {
display: flex;
height: 50px;
Expand Down Expand Up @@ -177,6 +182,7 @@ <h1>Marked.js Documentation</h1>

var content = document.querySelector('#content');
var body = document.querySelector('html');
var navLinks = document.querySelectorAll('nav a');
var currentPage = 'README.md';
var currentHash = '';
var renderedPage = '';
Expand Down Expand Up @@ -204,7 +210,14 @@ <h1>Marked.js Documentation</h1>
fetchAnchor(currentHash)
});

history.replaceState('', document.title, '#/' + currentPage + (currentHash ? '#' + currentHash : ''));
var url = '#/' + currentPage + (currentHash ? '#' + currentHash : '');
var fullUrl = window.location.origin + '/' + url;

navLinks.forEach(function(link) {
link.className = link.href === fullUrl ? 'selected' : '';
});

history.replaceState('', document.title, url);
}

function fetchAnchor(anchor) {
Expand Down

0 comments on commit ab89d59

Please sign in to comment.