-
Checklist
How did you create the site?Generated from DescriptionIs there a way to enable all h2~h6 headeres in TOC section? Operations you have already tried
Anything else?No response |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
@opabravo In case of Create a file !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 seems to work. |
Beta Was this translation helpful? Give feedback.
-
Here is the working solution. Create a file <script type="text/javascript" src="/assets/js/toc.js" defer></script> Then, create a javascript file document.querySelector("main h2, main h3")&&tocbot.refresh({
tocSelector:"#toc",
contentSelector:".content",
ignoreSelector:"[data-toc-skip]",
headingSelector:"h2, h3, h4, h5, h6",
orderedList:!1,
scrollSmooth:!1,
collapseDepth: 6
}); Here is tocbot documentation regarding available options. FYI @huanyushi @opabravo |
Beta Was this translation helpful? Give feedback.
Here is the working solution.
Create a file
_includes/metadata-hook.html
with the following content (this file is completely empty in Chirpy repo and is made specifically to include extra information into the<head>
section without the need to modify and support other files likehead.html
):Then, create a javascript file
assets/js/toc.js
to overrides TOC configuration e.g.: