diff --git a/javascripts/discourse/initializers/disco-toc-main.js b/javascripts/discourse/initializers/disco-toc-main.js index 13fd7ce..e9a47f3 100644 --- a/javascripts/discourse/initializers/disco-toc-main.js +++ b/javascripts/discourse/initializers/disco-toc-main.js @@ -41,7 +41,7 @@ export default { ":scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > h5"; const headings = el.querySelectorAll(dTocHeadingSelectors); - if (headings.length < 1) { + if (headings.length < settings.TOC_min_heading) { return; } diff --git a/settings.yml b/settings.yml index 4ca834a..2374341 100644 --- a/settings.yml +++ b/settings.yml @@ -20,3 +20,7 @@ auto_TOC_tags: type: list list_type: tag default: "" +TOC_min_heading: + default: 3 + min: 1 + max: 10000 diff --git a/test/acceptance/toc-test.js b/test/acceptance/toc-test.js index 0b38e69..17d5e62 100644 --- a/test/acceptance/toc-test.js +++ b/test/acceptance/toc-test.js @@ -125,6 +125,7 @@ acceptance("DiscoTOC - with categories", function (needs) { acceptance("DiscoTOC - non-text headings", function (needs) { needs.pretender((server, helper) => { + settings.TOC_min_heading = 1; const topicResponse = cloneJSON(topicFixtures["/t/280/1.json"]); topicResponse.post_stream.posts[0].cooked = `