website-zola/static/js/toc.js
2024-09-11 21:22:13 +02:00

16 lines
567 B
JavaScript

document.addEventListener('DOMContentLoaded', () => {
const tocTitle = document.querySelector('.toc-title');
const tocList = document.querySelector('.toc-list');
if (tocTitle && tocList) {
const toggleToC = () => {
const isExpanded = tocList.style.display === 'block' || window.getComputedStyle(tocList).display === 'block';
tocList.style.display = isExpanded ? 'none' : 'block';
tocTitle.classList.toggle('expanded', !isExpanded);
};
tocTitle.addEventListener('click', toggleToC);
}
});