fix: allow remark toc to parse headings with url
This commit is contained in:
parent
9c5e267a59
commit
b7cee5eaca
@ -1,12 +1,14 @@
|
||||
import { visit } from 'unist-util-visit'
|
||||
import { slug } from 'github-slugger'
|
||||
import { toString } from 'hast-util-to-string'
|
||||
|
||||
export default function remarkTocHeadings(options) {
|
||||
return (tree) =>
|
||||
visit(tree, 'heading', (node, index, parent) => {
|
||||
const textContent = toString(node)
|
||||
options.exportRef.push({
|
||||
value: node.children[0].value,
|
||||
url: '#' + slug(node.children[0].value),
|
||||
value: textContent,
|
||||
url: '#' + slug(textContent),
|
||||
depth: node.depth,
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user