tocbot.html 934 B

123456789101112131415161718192021222324252627282930
  1. <script src="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.4.2/tocbot.min.js" async></script>
  2. <script>
  3. const initToc = () => {
  4. if (window.tocbot === undefined) {
  5. setTimeout(initToc, 250)
  6. return
  7. }
  8. // Check whether we have any sidebar content. If not, then show the sidebar earlier.
  9. var SIDEBAR_CONTENT_TAGS = ['.tag_full_width', '.tag_popout'];
  10. var sidebar_content_query = SIDEBAR_CONTENT_TAGS.join(', ')
  11. if (document.querySelectorAll(sidebar_content_query).length === 0) {
  12. document.querySelector('nav.onthispage').classList.add('no_sidebar_content')
  13. }
  14. // Initialize the TOC bot
  15. tocbot.init({
  16. tocSelector: 'nav.onthispage',
  17. contentSelector: '.c-textbook__content',
  18. headingSelector: 'h2, h3',
  19. orderedList: false,
  20. collapseDepth: 6,
  21. listClass: 'toc__menu',
  22. activeListItemClass: "", // Not using
  23. activeLinkClass: "", // Not using
  24. });
  25. }
  26. initFunction(initToc);
  27. </script>