@frontendista/rehype-sectionize
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

rehype-sectionize

test workflow codecov

Motivation

There is already rehype-section in the library for sectioning. But it could not change the class of section. In addition, sections could not have the slug of heading in the data attribute. I was referred rehype-section. Thanks.

Install

npm i -D @hbsnow/rehype-sectionize

Sample

Input

<h1 id="h1-id">h1</h1>
<h2 id="h2-id">h2</h2>
<h3 id="h3-id">h3</h3>

Output

<section class="heading" data-heading-rank="1" aria-labelledby="h1-id">
  <h1 id="h1-id">h1</h1>
  <section class="heading" data-heading-rank="2" aria-labelledby="h2-id">
    <h2 id="h2-id">h2</h2>
    <section class="heading" data-heading-rank="3" aria-labelledby="h3-id">
      <h3 id="h3-id">h3</h3>
    </section>
  </section>
</section>

Options

option type default description
properties hastscript.Properties {} Attributes assigned to section
enableRootSection boolean false Section to wrap all
rankPropertyName string dataHeadingRank Name of rank data attribute
idPropertyName string ariaLabelledby Name of id data attribute

License

MIT © hbsnow

Readme

Keywords

Package Sidebar

Install

npm i @frontendista/rehype-sectionize

Weekly Downloads

1

Version

1.1.1

License

MIT

Unpacked Size

9.56 kB

Total Files

6

Last publish

Collaborators

  • pavelsusicky