jake-low / remark-sectionize

Remark plugin to wrap each heading and the content that follows it in a <section> tag
MIT License
63 stars 10 forks source link

Add depth prop to section #1

Closed shogotsuneto closed 5 years ago

shogotsuneto commented 5 years ago

Adding depth prop to section (from child heading depth).

Motivation

There can be a section depth of 6, directly under depth 1 (like in test.js#80). Besides, I like to write selector more straightforwardly.

Here is my example in React app: component

export default ({depth, children}) => <section className={styles[`section${depth}`]}>{children}</section>

CSS is like this.

I think accessing children[0].depth could spoil some flexibility. See caller of the above component.

I hope you consider merging this pull request.

jake-low commented 5 years ago

Hi @shogotsuneto, thanks so much for contributing this feature! I really like the idea and I'm happy to merge it. Seeing the example of how you're using this feature in your own code made it easy to understand the benefit.

jake-low commented 5 years ago

Okay, I've published version 1.1.0 to NPM; it includes your PR. Thanks again for contributing! 🙂

shogotsuneto commented 5 years ago

Thanks! Now I can use NPM version, not my fork!