web/_javascript/modules/components/toc.js
Cotes Chung e0950fc973
fix: make TOC title and entries visible at the same time (#1711)
When internet connection speeds are poor, there is a chance that the title of the TOC will appear earlier than its entries, causing a visual cutoff.
2024-04-29 03:36:16 +08:00

15 lines
425 B
JavaScript

export function toc() {
if (document.querySelector('main h2, main h3')) {
// see: https://github.com/tscanlin/tocbot#usage
tocbot.init({
tocSelector: '#toc',
contentSelector: '.content',
ignoreSelector: '[data-toc-skip]',
headingSelector: 'h2, h3, h4',
orderedList: false,
scrollSmooth: false
});
document.getElementById('toc-wrapper').classList.remove('d-none');
}
}