Skip to content

Commit b96abf5

Browse files
committed
write README
1 parent a8a2ed3 commit b96abf5

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,41 @@
11
# rehype-toc
22

3+
[![CI on main](https://github.com/mehm8128/rehype-toc/actions/workflows/main.yml/badge.svg)](https://github.com/mehm8128/rehype-toc/actions/workflows/main.yml)
4+
[![NPM Version](https://img.shields.io/npm/v/@mehm8128/rehype-toc)](https://www.npmjs.com/package/@mehm8128/rehype-toc)
5+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6+
37
rehype plugin to generate a table of contents from headings in your markdown.
48

59
You can create the table of contents such below.
610

711
![A table of contents whose each items are anchor link.](assets/toc.png)
12+
13+
## Installation
14+
15+
```bash
16+
pnpm install @mehm8128/rehype-toc
17+
```
18+
19+
## Usage
20+
21+
### astro.config.mjs
22+
23+
```ts
24+
import { rehypeCollapsableToc } from "@mehm8128/rehype-toc";
25+
26+
export default defineConfig({
27+
markdown: {
28+
rehypePlugins: [rehypeCollapsableToc],
29+
},
30+
});
31+
```
32+
33+
### rehype
34+
35+
```ts
36+
import { rehype } from "rehype"
37+
import { rehypeCollapsableToc } from "@mehm8128/rehype-toc";
38+
39+
const input = "<h2 id="heading-id"><a href="#heading-id">Heading</a></h2>";
40+
const { value } = await rehype().use(rehypeCollapsableToc).process(input);
41+
```

0 commit comments

Comments
 (0)