mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
18 lines
564 B
JavaScript
18 lines
564 B
JavaScript
//removes toc if not enough headings
|
|
(function() {
|
|
let tocLinks = document.querySelectorAll('#TableOfContents > ul a'),
|
|
toc = document.getElementById('toc');
|
|
if (toc && (tocLinks.length < 2)) {
|
|
toc.remove();
|
|
} else if (tocLinks.length > 1) {
|
|
document.getElementById('toc-toggle').addEventListener('click', toggleToc, false);
|
|
}
|
|
})();
|
|
|
|
function toggleToc(evt) {
|
|
evt.preventDefault();
|
|
evt.stopPropagation();
|
|
document.getElementById('toc').classList.toggle('toc-open');
|
|
document.getElementById('toc-toggle').classList.toggle('toc-open');
|
|
}
|