@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.
Files changed (2) hide show
  1. package/README.md +29 -9
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,21 +1,41 @@
1
1
  # rehype-toc
2
2
 
3
- ## Development
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)
4
6
 
5
- - Install dependencies:
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
+ ![A table of contents whose each items are anchor link.](assets/toc.png)
12
+
13
+ ## Installation
6
14
 
7
15
  ```bash
8
- pnpm install
16
+ pnpm install @mehm8128/rehype-toc
9
17
  ```
10
18
 
11
- - Run the unit tests:
19
+ ## Usage
12
20
 
13
- ```bash
14
- pnpm run test
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
- - Build the library:
33
+ ### rehype
18
34
 
19
- ```bash
20
- pnpm run build
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.0.0",
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 collapsable table of contents",
11
+ "description": "rehype plugin to generate a collapsible table of contents",
12
12
  "keywords": [
13
13
  "rehype",
14
14
  "toc",