Skip to content

Commit

Permalink
Merge pull request #3997 from SukkaW/toc-min-depth
Browse files Browse the repository at this point in the history
feat(toc_helper): add min_depth option
  • Loading branch information
SukkaW committed Dec 21, 2019
2 parents a381dda + 0cfb532 commit a4a3f82
Show file tree
Hide file tree
Showing 2 changed files with 278 additions and 70 deletions.
3 changes: 2 additions & 1 deletion lib/plugins/helper/toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ const { tocObj } = require('hexo-util');

function tocHelper(str, options = {}) {
options = Object.assign({
min_depth: 1,
max_depth: 6,
class: 'toc',
list_number: true
}, options);

const data = tocObj(str, { max_depth: options.max_depth });
const data = tocObj(str, { min_depth: options.min_depth, max_depth: options.max_depth });

if (!data.length) return '';

Expand Down

0 comments on commit a4a3f82

Please sign in to comment.