Skip to content

Conversation

noraj
Copy link
Contributor

@noraj noraj commented Dec 11, 2019

What does it do?

fix #3288

How to test

git clone -b BRANCH https://github.com/noraj/hexo.git
cd hexo
git checkout toc_min_depth
npm install
npm test
npm run eslint

Screenshots

Pull request tasks

  • Add test cases for the changes. [WIP] tests for toc plugin seem complex, so I begin to write them but I wasn't able to finish.
  • Passed the CI test. No, because tests are not finished.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0008%) to 97.136% when pulling dad6e85 on noraj:toc_min_depth into 8677963 on hexojs:master.

@@ -8,7 +8,8 @@ function tocHelper(str, options = {}) {

const $ = cheerio.load(str);
const headingsMaxDepth = Object.prototype.hasOwnProperty.call(options, 'max_depth') ? options.max_depth : 6;
const headingsSelector = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].slice(0, headingsMaxDepth).join(',');
const headingsMinDepth = Object.prototype.hasOwnProperty.call(options, 'min_depth') ? options.min_depth : 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use Object.assign to handle multiple default config.

@curbengh
Copy link
Contributor

Is this compatible with #3850?

@SukkaW
Copy link
Member

SukkaW commented Dec 12, 2019

@curbengh I could bring up #3850 (with hexo-util's tocObj()) over this PR then.

@curbengh
Copy link
Contributor

My understanding is that tocObj() implemented min_depth, so this PR should be superseded by #3850.

@SukkaW SukkaW closed this in #3997 Dec 21, 2019
@noraj noraj deleted the toc_min_depth branch December 21, 2019 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TOC helper: add min_depth
4 participants