Skip to content

How to enable TOC for all headers #1364

Closed Answered by kungfux
opabravo asked this question in Q&A
Discussion options

You must be logged in to vote

@opabravo In case of starter, there is no way to override javascript files, it seems. However, we can add our own. So, here is the solution for blogs created by starter:

Create a file assets\js\custom-toc.js with the configuration you want:

!function(){
    "use strict";
    document.querySelector("main h2, main h3")&&tocbot.init({
        tocSelector:"#toc",
        contentSelector:".content",
        ignoreSelector:"[data-toc-skip]",
        headingSelector:"h2, h3, h4, h5, h6",
        orderedList:!1,
        scrollSmooth:!1
    })}();

Since custom scripts are being executed later, it overrides configuration successfully. However, I'm not sure this will work stable for 100%, but it see…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@opabravo
Comment options

Comment options

You must be logged in to vote
3 replies
@huanyushi
Comment options

@kungfux
Comment options

@huanyushi
Comment options

Answer selected by MrMurdock11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants