[new option] tocLevels
Sometimes, toc doen't work correctly. This option fixes the issue.
This commit is contained in:
parent
5a42616dc9
commit
a447d1561c
|
@ -285,6 +285,7 @@ tocFolding = false
|
||||||
enableTocSwitch = true # single page table of contents visibility switch
|
enableTocSwitch = true # single page table of contents visibility switch
|
||||||
itemsPerCategory = 5 # maximum number of posts shown in the sidebar.
|
itemsPerCategory = 5 # maximum number of posts shown in the sidebar.
|
||||||
sidebarPosition = "right" # bio, profile component layout position
|
sidebarPosition = "right" # bio, profile component layout position
|
||||||
|
tocLevels = ["h2", "h3", "h4"] # minimum h2, maximum h4 in your article
|
||||||
|
|
||||||
# footer
|
# footer
|
||||||
showPoweredBy = true # show footer text: Powered by Hugo and Zzo theme
|
showPoweredBy = true # show footer text: Powered by Hugo and Zzo theme
|
||||||
|
|
|
@ -293,6 +293,7 @@ tocFolding = false
|
||||||
enableTocSwitch = true # single page table of contents visibility switch
|
enableTocSwitch = true # single page table of contents visibility switch
|
||||||
itemsPerCategory = 5 # maximum number of posts shown in the sidebar.
|
itemsPerCategory = 5 # maximum number of posts shown in the sidebar.
|
||||||
sidebarPosition = "right" # bio, profile component layout position
|
sidebarPosition = "right" # bio, profile component layout position
|
||||||
|
tocLevels = ["h2", "h3", "h4"] # minimum h2, maximum h4 in your article
|
||||||
|
|
||||||
# footer
|
# footer
|
||||||
showPoweredBy = true # show footer text: Powered by Hugo and Zzo theme
|
showPoweredBy = true # show footer text: Powered by Hugo and Zzo theme
|
||||||
|
|
|
@ -7,6 +7,7 @@ hideToc: false
|
||||||
enableToc: true
|
enableToc: true
|
||||||
enableTocContent: false
|
enableTocContent: false
|
||||||
tocPosition: inner
|
tocPosition: inner
|
||||||
|
tocLevels: ["h2", "h3", "h4"]
|
||||||
tags:
|
tags:
|
||||||
-
|
-
|
||||||
series:
|
series:
|
||||||
|
|
|
@ -55,6 +55,7 @@ tocPosition = "inner" # inner, outer
|
||||||
enableTocSwitch = true
|
enableTocSwitch = true
|
||||||
itemsPerCategory = 5
|
itemsPerCategory = 5
|
||||||
sidebarPosition = "right"
|
sidebarPosition = "right"
|
||||||
|
tocLevels = ["h2", "h3", "h4"]
|
||||||
|
|
||||||
# footer
|
# footer
|
||||||
showPoweredBy = true
|
showPoweredBy = true
|
||||||
|
|
|
@ -214,11 +214,19 @@
|
||||||
|
|
||||||
{{ $tocFolding := $.Param "tocFolding" }}
|
{{ $tocFolding := $.Param "tocFolding" }}
|
||||||
var tocFolding = JSON.parse({{ $tocFolding | jsonify }});
|
var tocFolding = JSON.parse({{ $tocFolding | jsonify }});
|
||||||
|
{{ $tocLevels := ($.Param "tocLevels") }}
|
||||||
|
var tocLevels = JSON.parse({{ $tocLevels | jsonify }});
|
||||||
|
|
||||||
|
if (tocLevels) {
|
||||||
|
tocLevels = tocLevels.toString();
|
||||||
|
} else {
|
||||||
|
tocLevels = "h1, h2, h3, h4, h5, h6";
|
||||||
|
}
|
||||||
|
|
||||||
// tab
|
// tab
|
||||||
singleContentsElem && singleContentsElem.querySelectorAll(".tab") ?
|
singleContentsElem && singleContentsElem.querySelectorAll(".tab") ?
|
||||||
singleContentsElem.querySelectorAll(".tab").forEach(function (elem) {
|
singleContentsElem.querySelectorAll(".tab").forEach(function (elem) {
|
||||||
elem.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach(function (element) {
|
elem.querySelectorAll(tocLevels).forEach(function (element) {
|
||||||
notAllowedTitleIds = Array.isArray(notAllowedTitleIds) ?
|
notAllowedTitleIds = Array.isArray(notAllowedTitleIds) ?
|
||||||
notAllowedTitleIds.concat(element.getAttribute('id')) :
|
notAllowedTitleIds.concat(element.getAttribute('id')) :
|
||||||
[element.getAttribute('id')];
|
[element.getAttribute('id')];
|
||||||
|
@ -227,7 +235,7 @@
|
||||||
|
|
||||||
// expand
|
// expand
|
||||||
expandContents ? expandContents.forEach(function(elem) {
|
expandContents ? expandContents.forEach(function(elem) {
|
||||||
elem.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach(function (element) {
|
elem.querySelectorAll(tocLevels).forEach(function (element) {
|
||||||
notAllowedTitleIds = Array.isArray(notAllowedTitleIds) ?
|
notAllowedTitleIds = Array.isArray(notAllowedTitleIds) ?
|
||||||
notAllowedTitleIds.concat(element.getAttribute('id')) :
|
notAllowedTitleIds.concat(element.getAttribute('id')) :
|
||||||
[element.getAttribute('id')];
|
[element.getAttribute('id')];
|
||||||
|
@ -236,7 +244,7 @@
|
||||||
|
|
||||||
// box
|
// box
|
||||||
boxContents ? boxContents.forEach(function(elem) {
|
boxContents ? boxContents.forEach(function(elem) {
|
||||||
elem.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach(function (element) {
|
elem.querySelectorAll(tocLevels).forEach(function (element) {
|
||||||
notAllowedTitleIds = Array.isArray(notAllowedTitleIds) ?
|
notAllowedTitleIds = Array.isArray(notAllowedTitleIds) ?
|
||||||
notAllowedTitleIds.concat(element.getAttribute('id')) :
|
notAllowedTitleIds.concat(element.getAttribute('id')) :
|
||||||
[element.getAttribute('id')];
|
[element.getAttribute('id')];
|
||||||
|
@ -266,8 +274,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (singleContentsElem) {
|
if (singleContentsElem) {
|
||||||
if (singleContentsElem.querySelectorAll("h1, h2, h3, h4, h5, h6").length > 0) {
|
if (singleContentsElem.querySelectorAll(tocLevels).length > 0) {
|
||||||
singleContentsElem.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach(function (elem) {
|
singleContentsElem.querySelectorAll(tocLevels).forEach(function (elem) {
|
||||||
if (toggleTocElem && !toggleTocElem.checked) {
|
if (toggleTocElem && !toggleTocElem.checked) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -336,8 +344,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (singleContentsElem) {
|
if (singleContentsElem) {
|
||||||
if (singleContentsElem.querySelectorAll("h1, h2, h3, h4, h5, h6").length > 0) {
|
if (singleContentsElem.querySelectorAll(tocLevels).length > 0) {
|
||||||
singleContentsElem.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach(function (elem) {
|
singleContentsElem.querySelectorAll(tocLevels).forEach(function (elem) {
|
||||||
if (toggleTocElem && !toggleTocElem.checked) {
|
if (toggleTocElem && !toggleTocElem.checked) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue