Skip to content

Commit

Permalink
Static method isn't a thing on this version? (github#17580)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonEtco authored Jan 29, 2021
1 parent 1bf9367 commit f2c08b3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/render-content/plugins/use-english-headings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const GithubSlugger = require('github-slugger')
const Entities = require('html-entities').XmlEntities
const toString = require('hast-util-to-string')
const visit = require('unist-util-visit')
const slugger = new GithubSlugger()
const entities = new Entities()

const matcher = node => (
Expand All @@ -14,12 +15,13 @@ module.exports = function useEnglishHeadings ({ englishHeadings }) {
if (!englishHeadings) return
return tree => {
visit(tree, matcher, node => {
slugger.reset()
// Get the plain text content of the heading node
const text = toString(node)
// find English heading in the collection
const englishHeading = englishHeadings[entities.encode(text)]
// get English slug
const englishSlug = GithubSlugger.slug(englishHeading)
const englishSlug = slugger.slug(englishHeading)
// use English slug for heading ID and link
node.properties.id = englishSlug
})
Expand Down

0 comments on commit f2c08b3

Please sign in to comment.