File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
lib/render-content/plugins Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ const GithubSlugger = require('github-slugger')
2
2
const Entities = require ( 'html-entities' ) . XmlEntities
3
3
const toString = require ( 'hast-util-to-string' )
4
4
const visit = require ( 'unist-util-visit' )
5
+ const slugger = new GithubSlugger ( )
5
6
const entities = new Entities ( )
6
7
7
8
const matcher = node => (
@@ -14,12 +15,13 @@ module.exports = function useEnglishHeadings ({ englishHeadings }) {
14
15
if ( ! englishHeadings ) return
15
16
return tree => {
16
17
visit ( tree , matcher , node => {
18
+ slugger . reset ( )
17
19
// Get the plain text content of the heading node
18
20
const text = toString ( node )
19
21
// find English heading in the collection
20
22
const englishHeading = englishHeadings [ entities . encode ( text ) ]
21
23
// get English slug
22
- const englishSlug = GithubSlugger . slug ( englishHeading )
24
+ const englishSlug = slugger . slug ( englishHeading )
23
25
// use English slug for heading ID and link
24
26
node . properties . id = englishSlug
25
27
} )
You can’t perform that action at this time.
0 commit comments