@mehm8128/rehype-toc 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,21 +1,41 @@
|
|
|
1
1
|
# rehype-toc
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/mehm8128/rehype-toc/actions/workflows/main.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@mehm8128/rehype-toc)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
rehype plugin to generate a table of contents from headings in your markdown.
|
|
8
|
+
|
|
9
|
+
You can create the table of contents as follows.
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## Installation
|
|
6
14
|
|
|
7
15
|
```bash
|
|
8
|
-
pnpm install
|
|
16
|
+
pnpm install @mehm8128/rehype-toc
|
|
9
17
|
```
|
|
10
18
|
|
|
11
|
-
|
|
19
|
+
## Usage
|
|
12
20
|
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
### astro.config.mjs
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { rehypeCollapsibleToc } from "@mehm8128/rehype-toc";
|
|
25
|
+
|
|
26
|
+
export default defineConfig({
|
|
27
|
+
markdown: {
|
|
28
|
+
rehypePlugins: [rehypeCollapsibleToc],
|
|
29
|
+
},
|
|
30
|
+
});
|
|
15
31
|
```
|
|
16
32
|
|
|
17
|
-
|
|
33
|
+
### rehype
|
|
18
34
|
|
|
19
|
-
```
|
|
20
|
-
|
|
35
|
+
```ts
|
|
36
|
+
import { rehype } from "rehype"
|
|
37
|
+
import { rehypeCollapsibleToc } 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(rehypeCollapsibleToc).process(input);
|
|
21
41
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mehm8128/rehype-toc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"homepage": "https://github.com/mehm8128/rehype-toc",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"description": "rehype plugin to generate a
|
|
11
|
+
"description": "rehype plugin to generate a collapsible table of contents",
|
|
12
12
|
"keywords": [
|
|
13
13
|
"rehype",
|
|
14
14
|
"toc",
|