Skip to content

Commit 963f30c

Browse files
committed
Refactor docs
1 parent 463cd39 commit 963f30c

File tree

1 file changed

+47
-25
lines changed

1 file changed

+47
-25
lines changed

readme.md

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* [Use](#use)
1919
* [API](#api)
2020
* [`unified().use(rehypeSlug[, options])`](#unifieduserehypeslug-options)
21+
* [`Options`](#options)
2122
* [Types](#types)
2223
* [Compatibility](#compatibility)
2324
* [Security](#security)
@@ -50,8 +51,8 @@ more easily link to particular sections.
5051

5152
## Install
5253

53-
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
54-
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
54+
This package is [ESM only][esm].
55+
In Node.js (version 16+), install with [npm][]:
5556

5657
```sh
5758
npm install rehype-slug
@@ -83,7 +84,7 @@ Say we have the following file `example.html`:
8384
<h5>elit</h5>
8485
```
8586

86-
And our module `example.js` looks as follows:
87+
…and our module `example.js` looks as follows:
8788

8889
```js
8990
import {read} from 'to-vfile'
@@ -98,7 +99,7 @@ const file = await rehype()
9899
console.log(String(file))
99100
```
100101

101-
Now, running `node example.js` yields:
102+
…then running `node example.js` yields:
102103

103104
```html
104105
<h1 id="some-id">Lorem ipsum</h1>
@@ -111,31 +112,44 @@ Now, running `node example.js` yields:
111112
## API
112113

113114
This package exports no identifiers.
114-
The default export is `rehypeSlug`.
115+
The default export is [`rehypeSlug`][api-rehype-slug].
115116

116117
### `unified().use(rehypeSlug[, options])`
117118

118119
Add `id`s to headings.
119120

120-
##### `options`
121+
###### Parameters
121122

122-
Configuration (optional).
123+
* `options` ([`Options`][api-options], optional)
124+
— configuration
123125

124-
###### `options.prefix`
126+
###### Returns
125127

126-
Prefix to add in front of `id`s (`string`, default: `''`).
128+
Transform ([`Transformer`][unified-transformer]).
129+
130+
### `Options`
131+
132+
Configuration (TypeScript type).
133+
134+
###### Fields
135+
136+
* `prefix` (`string`, default: `''`)
137+
— prefix to add in front of `id`s
127138

128139
## Types
129140

130141
This package is fully typed with [TypeScript][].
131-
It exports the additional type `Options`.
142+
It exports the additional type [`Options`][api-options].
132143

133144
## Compatibility
134145

135-
Projects maintained by the unified collective are compatible with all maintained
146+
Projects maintained by the unified collective are compatible with maintained
136147
versions of Node.js.
137-
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
138-
Our projects sometimes work with older versions, but this is not guaranteed.
148+
149+
When we cut a new major release, we drop support for unmaintained versions of
150+
Node.
151+
This means we try to keep the current release line, `rehype-slug@^5`,
152+
compatible with Node.js 12.
139153

140154
This plugin works with `rehype-parse` version 1+, `rehype-stringify` version 1+,
141155
`rehype` version 1+, and `unified` version 4+.
@@ -182,9 +196,9 @@ abide by its terms.
182196

183197
[downloads]: https://www.npmjs.com/package/rehype-slug
184198

185-
[size-badge]: https://img.shields.io/bundlephobia/minzip/rehype-slug.svg
199+
[size-badge]: https://img.shields.io/bundlejs/size/rehype-slug
186200

187-
[size]: https://bundlephobia.com/result?p=rehype-slug
201+
[size]: https://bundlejs.com/?q=rehype-slug
188202

189203
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
190204

@@ -198,32 +212,40 @@ abide by its terms.
198212

199213
[npm]: https://docs.npmjs.com/cli/install
200214

215+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
216+
201217
[esmsh]: https://esm.sh
202218

203219
[health]: https://github.com/rehypejs/.github
204220

205-
[contributing]: https://github.com/rehypejs/.github/blob/HEAD/contributing.md
221+
[contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md
206222

207-
[support]: https://github.com/rehypejs/.github/blob/HEAD/support.md
223+
[support]: https://github.com/rehypejs/.github/blob/main/support.md
208224

209-
[coc]: https://github.com/rehypejs/.github/blob/HEAD/code-of-conduct.md
225+
[coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md
210226

211227
[license]: license
212228

213229
[author]: https://wooorm.com
214230

215-
[typescript]: https://www.typescriptlang.org
216-
217-
[unified]: https://github.com/unifiedjs/unified
231+
[github-slugger]: https://github.com/Flet/github-slugger
218232

219233
[rehype]: https://github.com/rehypejs/rehype
220234

221-
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
222-
223-
[github-slugger]: https://github.com/Flet/github-slugger
224-
225235
[rehype-autolink-headings]: https://github.com/rehypejs/rehype-autolink-headings
226236

227237
[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize
228238

229239
[rehype-sanitize-example]: https://github.com/rehypejs/rehype-sanitize#example-headings-dom-clobbering
240+
241+
[typescript]: https://www.typescriptlang.org
242+
243+
[unified]: https://github.com/unifiedjs/unified
244+
245+
[unified-transformer]: https://github.com/unifiedjs/unified#transformer
246+
247+
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
248+
249+
[api-options]: #options
250+
251+
[api-rehype-slug]: #unifieduserehypeslug-options

0 commit comments

Comments
 (0)