This is probably the most useful markdown article structure tree component. With this component, you can:
- Displays a table of contents for the reader
- Click the table of contents to jump to the corresponding content of the article
- Share urls with anchor hash values with readers
Best markdown navigation bar for React.
git repo
Install
yarn add markdown-navbar
Copy the code
or
npm install markdown-navbar
Copy the code
Usage
import MarkNav from 'markdown-navbar';
import 'markdown-navbar/dist/navbar.css';
const content = '## Heading One... \n\n## Heading Two... \n';
<MarkNav
className="article-menu"
source={content}
headingTopOffset={80}
/>
Copy the code
Screenshots
Options
Property | Data Type | Default Value | Description |
---|---|---|---|
className | string | “” | The className that defines the outermost container of navbar |
source | string | “” | Markdown text content |
headingTopOffset | number | 0 | Anchor displacement relative to the top of the window (for the anchor jump) |
updateHashAuto | boolean | true | Automatically update the hash value of browser address when page scrolling if true |
declarative | boolean | false | Use the text of the title from Markdown content as the hash value for the anchor if true |
ordered | boolean | true | Whether the title contains a numerical prefix, such as: 1. 2. 2.2 |
License
MIT