@govuk-frederic/table-of-contents

0.2.0 • Public • Published

TableOfContents

Import

  import TableOfContents from '@govuk-frederic/table-of-contents';

Usage

Simple

<TOC.Container>
  <TOC.Index>
    {
      ({ contents }) =>
        <ul>
          {
            contents.map(
              ({ id, title }) => <li key={id}><a href={`#${id}`}>{title}</a></li>
            )
          }
        </ul>
    }
  </TOC.Index>
  <TOC.Section id="first" title="First">
    <h2>First</h2>
    <p>
      Section content goes here
    </p>
  </TOC.Section>
  <TOC.Section id="second" title="Second">
    <h2>Second</h2>
    <p>
      Section content goes here
    </p>
  </TOC.Section>
</TOC.Container>

Readme

Keywords

none

Package Sidebar

Install

npm i @govuk-frederic/table-of-contents

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

84.1 kB

Total Files

39

Last publish

Collaborators

  • loque-
  • penx
  • petelockey
  • steve_sims