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() {
2626 let slugify = slugifyWithCounter ( )
2727 visit ( tree , 'element' , ( node ) => {
2828 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+ } )
3033 }
3134 } )
3235 }
Original file line number Diff line number Diff line change 11import { visit } from 'unist-util-visit'
22import { toString } from 'mdast-util-to-string'
33import { remark } from 'remark'
4- import slugify from 'slugify'
4+ import { slugifyWithCounter } from '@sindresorhus/ slugify'
55
66/**
77 * Extracts TOC headings from markdown file and adds it to the file's data object.
88 */
99export const remarkTocHeadings =
1010 ( includedDepths = [ 2 ] ) =>
1111 ( ) => {
12+ const slugify = slugifyWithCounter ( )
13+
1214 return ( tree , file ) => {
1315 const toc = [ ]
1416 visit ( tree , 'heading' , ( node ) => {
@@ -20,8 +22,8 @@ export const remarkTocHeadings =
2022 url :
2123 '#' +
2224 slugify ( textContent , {
23- lower : true ,
24- strict : true ,
25+ decamelize : false ,
26+ customReplacements : [ [ '’' , '' ] ] ,
2527 } ) ,
2628 depth : node . depth ,
2729 } )
You can’t perform that action at this time.
0 commit comments