tscanlin / tocbot

Build a table of contents from headings in an HTML document.
MIT License
1.39k stars 115 forks source link

No highlight in Hugo Dream template #326

Closed cedricwalter closed 9 months ago

cedricwalter commented 9 months ago

Thanks for TocBot, I tried to make it work on my site (Hugo + dream template)

Site: https://waltercedric.com/rc-helicopter-airplanes-fpv-drone/master-the-skies-with-the-omp-hobby-m2-evo-a-thrilling-adventure-into-rc-helicopter-enthusiasm/

the highlighting don't work and sub menu don't open ex on "Setting up the OMP Hobby M2 Evo"

I see no error in the javascript console, I tried with hasInnerContainers: false and hasInnerContainers: true

I moved the edit code to the head or bottom, always in a document.ready()

I removed some library to see if one is conflicting. I removed from the code the Hugo {{ .TableOfContents }} so only TocoBot can create the table of content.

I tried in Firefox, Chrome, Safari, same result.

I run out of ideas :-)

thanks for any help or guidance

cedricwalter commented 9 months ago

I just found the offending code:

ar e,
    a = $('body')
      .overlayScrollbars({
        className: (
          window.backgroundDark || window.backgroundImageDark
            ? 'y' === localStore.getItem('hugo-theme-dream-is-dark')
            : window.darkNav
        )
          ? 'os-theme-light'
          : 'os-theme-dark',
        scrollbars: { autoHide: 'scroll', clickScrolling: !0 },
      })
      .overlayScrollbars()
  window.fixedNav &&
    ((e = $('.dream-nav')),
    a.options('callbacks.onScroll', function () {
      var a = this.scroll().position.y,
        o = $('.fake-dream-nav')
      0 < a
        ? (e.addClass('fixed').css('background', 'y' === window.isDark ? window.backgroundDark : window.background),
          $('.dream-single-aside').css('top', 54),
          o.length || $('<div class="fake-dream-nav" />').css('height', 54).insertBefore(e))
        : (e.removeClass('fixed').css('background', 'unset'), $('.dream-single-aside').css('top', 0), o.remove())
    })),
    (window.overlayScrollbarsInstance = a),
    $('.dream-flip-toggle').click(function () {
      $('.flip-container').toggleClass('flip-it')
    })
cedricwalter commented 9 months ago

I remove the window.overlayScrollbarsInstance, so I can close the ticket, maybe you have a better solution?