K-Sato1995 / react-auto-toc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-auto-toc

⚠️I made a new package which serves the same purpose. Plese use react-toc instead.⚠️

Automatically create a table of contents.

NPM JavaScript Style Guide

Description

The idea is that you can automatically create a table of contents from your markdown text.

PRs/Issues are always welcome.

Install

npm install --save react-auto-toc

Usage

Pass your markdown content as a prop.

import React, { Component } from 'react'
import Toc from 'react-auto-toc'

class Example extends Component {
  render() {
    const content = '# test \n your markdown Content # test2\n'
    return <Toc markdownText={content} />
  }
}

output2

Custom style

The list(ul) has a class called toc-list and each item(li) has header1, header2 or header3 as its class. Lastly, every title(a) has a class called toc-title.

You can add styles to them in your css files.

License

MIT © K-Sato1995

About


Languages

Language:JavaScript 93.5%Language:HTML 4.2%Language:CSS 2.3%