Skip to content

Commit 3c32def

Browse files
committed
feat!: fork package to new name, update docs
1 parent 9517933 commit 3c32def

File tree

4 files changed

+33
-76
lines changed

4 files changed

+33
-76
lines changed

.github/workflows/bb.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

license

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(The MIT License)
22

3-
Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com>
3+
Copyright (c) 2022 Unicorn Utterances Contributors <github@unicorn-utterances.com>
44

55
Permission is hereby granted, free of charge, to any person obtaining
66
a copy of this software and associated documentation files (the

package.json

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "rehype-slug",
3-
"version": "5.0.0",
4-
"description": "rehype plugin to add `id` attributes to headings",
2+
"name": "rehype-slug-custom-id",
3+
"version": "1.0.0",
4+
"description": "plugin to add `id` attributes to headings similar to gatsby-remark-autolink-headers ",
55
"license": "MIT",
66
"keywords": [
77
"unified",
@@ -13,16 +13,8 @@
1313
"slug",
1414
"id"
1515
],
16-
"repository": "rehypejs/rehype-slug",
17-
"bugs": "https://github.com/rehypejs/rehype-slug/issues",
18-
"funding": {
19-
"type": "opencollective",
20-
"url": "https://opencollective.com/unified"
21-
},
22-
"author": "Titus Wormer <[email protected]> (https://wooorm.com)",
23-
"contributors": [
24-
"Titus Wormer <[email protected]> (https://wooorm.com)"
25-
],
16+
"repository": "unicorn-utterances/rehype-slug-custom-id",
17+
"bugs": "https://github.com/unicorn-utterances/rehype-slug-custom-id/issues",
2618
"sideEffects": false,
2719
"type": "module",
2820
"types": "index.d.ts",

readme.md

Lines changed: 27 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
# rehype-slug
1+
# rehype-slug-custom-id
22

33
[![Build][build-badge]][build]
44
[![Coverage][coverage-badge]][coverage]
55
[![Downloads][downloads-badge]][downloads]
66
[![Size][size-badge]][size]
7-
[![Sponsors][sponsors-badge]][collective]
8-
[![Backers][backers-badge]][collective]
9-
[![Chat][chat-badge]][chat]
107

11-
[**rehype**][rehype] plugin to add `id`s to headings.
8+
[**rehype**][rehype] plugin to add `id`s to headings with the option for custom IDs.
129

1310
## Install
1411

@@ -18,7 +15,7 @@ Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
1815
[npm][]:
1916

2017
```sh
21-
npm install rehype-slug
18+
npm install rehype-slug-custom-id
2219
```
2320

2421
## Use
@@ -31,6 +28,7 @@ Say we have the following file, `fragment.html`:
3128
<h3>consectetur &amp; adipisicing</h3>
3229
<h4>elit</h4>
3330
<h5>elit</h5>
31+
<h6>Custom ID Should Be Here {#custom-id}</h6>
3432
```
3533

3634
And our script, `example.js`, looks as follows:
@@ -59,18 +57,28 @@ Now, running `node example` yields:
5957
<h3 id="consectetur--adipisicing">consectetur &#x26; adipisicing</h3>
6058
<h4 id="elit">elit</h4>
6159
<h5 id="elit-1">elit</h5>
60+
<h6 id="custom-id">Custom ID Should Be Here</h6>
6261
```
6362

6463
## API
6564

66-
This package exports no identifiers.
6765
The default export is `rehypeSlug`.
6866

6967
### `unified().use(rehypeSlug)`
7068

7169
Add `id` properties to h1-h6 headings that don’t already have one.
7270

73-
Uses [**github-slugger**][ghslug] to create GitHub style `id`s.
71+
Uses [**github-slugger**][ghslug] to create GitHub style `id`s, or a custom ID if supplied like so:
72+
73+
```html
74+
<h1>ID {#custom-id-here}</h1>
75+
```
76+
77+
We support the following options for the plugin:
78+
79+
- `enableCustomId`: `Boolean`. Enable custom header IDs with {#id} (optional)
80+
- `maintainCase`: `Boolean`. Maintains the case for markdown header (optional)
81+
- `removeAccents`: `Boolean`. Remove accents from generated headings IDs (optional)
7482

7583
## Security
7684

@@ -84,65 +92,35 @@ Always be wary with user input and use [`rehype-sanitize`][sanitize].
8492

8593
## Related
8694

87-
* [`remark-slug`](https://github.com/wooorm/remark-slug)
95+
* [`rehype-slug`](https://github.com/rehypejs/rehype-slug)
96+
— Add slugs to headings in html
97+
* [`remark-slug`](https://github.com/wooorm/remark-slug)
8898
— Add slugs to headings in markdown
89-
90-
## Contribute
91-
92-
See [`contributing.md`][contributing] in [`rehypejs/.github`][health] for ways
93-
to get started.
94-
See [`support.md`][support] for ways to get help.
95-
96-
This project has a [code of conduct][coc].
97-
By interacting with this repository, organization, or community you agree to
98-
abide by its terms.
99-
100-
## License
101-
102-
[MIT][license] © [Titus Wormer][author]
99+
* [`gatsby-remark-autolink-headers`](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-remark-autolink-headers)
100+
— Add slugs to headings in markdown for Gatsby
103101

104102
<!-- Definitions -->
105103

106-
[build-badge]: https://github.com/rehypejs/rehype-slug/workflows/main/badge.svg
104+
[build-badge]: https://github.com/unicorn-utterances/rehype-slug-custom-id/workflows/main/badge.svg
107105

108-
[build]: https://github.com/rehypejs/rehype-slug/actions
106+
[build]: https://github.com/unicorn-utterances/rehype-slug-custom-id/actions
109107

110-
[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-slug.svg
108+
[coverage-badge]: https://img.shields.io/codecov/c/github/unicorn-utterances/rehype-slug-custom-id.svg
111109

112-
[coverage]: https://codecov.io/github/rehypejs/rehype-slug
110+
[coverage]: https://codecov.io/github/unicorn-utterances/rehype-slug-custom-id
113111

114112
[downloads-badge]: https://img.shields.io/npm/dm/rehype-slug.svg
115113

116-
[downloads]: https://www.npmjs.com/package/rehype-slug
114+
[downloads]: https://www.npmjs.com/package/rehype-slug-custom-id
117115

118-
[size-badge]: https://img.shields.io/bundlephobia/minzip/rehype-slug.svg
116+
[size-badge]: https://img.shields.io/bundlephobia/minzip/rehype-slug-custom-id.svg
119117

120118
[size]: https://bundlephobia.com/result?p=rehype-slug
121119

122-
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
123-
124-
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
125-
126-
[collective]: https://opencollective.com/unified
127-
128-
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
129-
130-
[chat]: https://github.com/rehypejs/rehype/discussions
131-
132120
[npm]: https://docs.npmjs.com/cli/install
133121

134-
[health]: https://github.com/rehypejs/.github
135-
136-
[contributing]: https://github.com/rehypejs/.github/blob/HEAD/contributing.md
137-
138-
[support]: https://github.com/rehypejs/.github/blob/HEAD/support.md
139-
140-
[coc]: https://github.com/rehypejs/.github/blob/HEAD/code-of-conduct.md
141-
142122
[license]: license
143123

144-
[author]: https://wooorm.com
145-
146124
[rehype]: https://github.com/rehypejs/rehype
147125

148126
[ghslug]: https://github.com/Flet/github-slugger

0 commit comments

Comments
 (0)