Skip to content

Commit

Permalink
fix bug with certain headings (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
tscanlin authored Oct 21, 2021
1 parent 27abc7a commit bd4a8a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/Template/Tocbot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
const TOCBOT_OPTIONS = {
tocSelector: '.js-toc',
contentSelector: '.js-toc-content',
headingSelector: 'h2, h3, h4',
headingSelector: 'h2, h3, h4, h5, h6',
positionFixedSelector: '.js-toc',
includeHtml: true,
includeTitleTags: false,
Expand Down
5 changes: 4 additions & 1 deletion src/js/parse-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ module.exports = function parseContent (options) {

while (counter > 0) {
lastItem = getLastItem(array)
if (lastItem && lastItem.children !== undefined) {
// Handle case where there are multiple h5+ in a row.
if (lastItem && level === lastItem.headingLevel) {
break
} else if (lastItem && lastItem.children !== undefined) {
array = lastItem.children
}
counter--
Expand Down

0 comments on commit bd4a8a8

Please sign in to comment.