Skip to content

Commit

Permalink
fix: use header's slug as it is if possible (#119)
Browse files Browse the repository at this point in the history
Hyunje Jun authored and yyx990803 committed Apr 18, 2018

Verified

This commit was signed with the committer’s verified signature. The key has expired.
tonistiigi Tõnis Tiigi
1 parent c4772f4 commit 5f7e199
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/util/index.js
Original file line number Diff line number Diff line change
@@ -59,10 +59,11 @@ exports.extractHeaders = (content, include = [], md) => {
tokens.forEach((t, i) => {
if (t.type === 'heading_open' && include.includes(t.tag)) {
const title = tokens[i + 1].content
const slug = t.attrs.find(([name]) => name === 'id')[1]
res.push({
level: parseInt(t.tag.slice(1), 10),
title,
slug: md.slugify(title)
slug: slug || md.slugify(title)
})
}
})

0 comments on commit 5f7e199

Please sign in to comment.