Add heading id links

This commit is contained in:
Mahdi Dibaiee
2015-07-31 10:21:07 +04:30
parent f3d5929613
commit f577d6c9c5
4 changed files with 48 additions and 0 deletions

12
js/heading-links.js Normal file
View File

@ -0,0 +1,12 @@
(function() {
var els = document.querySelectorAll('.post-content [id]');
var headings = Array.prototype.slice.call(els);
headings.forEach(function(head) {
var link = document.createElement('a');
link.className = 'heading-link';
link.href = '#' + head.id;
head.appendChild(link);
});
}());