<% if(is_post() && theme.post.toc.enable && page.toc != false){ %>
  <%- js_ex(theme.static_prefix.tocbot, '/tocbot.min.js') %>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: 'article.markdown-body',
        headingSelector: '<%= theme.post.toc.headingSelector || "h1,h2,h3,h4,h5,h6" %>',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: <%= theme.post.toc.collapseDepth || 0 %>,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>
<% } %>
