This repository was archived by the owner on May 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,10 @@ function rehypeSlugify() {
26
26
let slugify = slugifyWithCounter ( )
27
27
visit ( tree , 'element' , ( node ) => {
28
28
if ( ALLOWED_TAGS . includes ( node . tagName ) && ! node . properties . id ) {
29
- node . properties . id = slugify ( toString ( node ) )
29
+ node . properties . id = slugify ( toString ( node ) , {
30
+ decamelize : false ,
31
+ customReplacements : [ [ '’' , '' ] ] ,
32
+ } )
30
33
}
31
34
} )
32
35
}
Original file line number Diff line number Diff line change 1
1
import { visit } from 'unist-util-visit'
2
2
import { toString } from 'mdast-util-to-string'
3
3
import { remark } from 'remark'
4
- import slugify from 'slugify'
4
+ import { slugifyWithCounter } from '@sindresorhus/ slugify'
5
5
6
6
/**
7
7
* Extracts TOC headings from markdown file and adds it to the file's data object.
8
8
*/
9
9
export const remarkTocHeadings =
10
10
( includedDepths = [ 2 ] ) =>
11
11
( ) => {
12
+ const slugify = slugifyWithCounter ( )
13
+
12
14
return ( tree , file ) => {
13
15
const toc = [ ]
14
16
visit ( tree , 'heading' , ( node ) => {
@@ -20,8 +22,8 @@ export const remarkTocHeadings =
20
22
url :
21
23
'#' +
22
24
slugify ( textContent , {
23
- lower : true ,
24
- strict : true ,
25
+ decamelize : false ,
26
+ customReplacements : [ [ '’' , '' ] ] ,
25
27
} ) ,
26
28
depth : node . depth ,
27
29
} )
You can’t perform that action at this time.
0 commit comments