jonbio/lib/remark-toc-headings.js
2021-08-14 23:11:18 +08:00

13 lines
368 B
JavaScript

import { visit } from 'unist-util-visit'
export default function remarkTocHeadings(options) {
return (tree) =>
visit(tree, 'heading', (node, index, parent) => {
options.exportRef.push({
value: node.children[0].value || node.children[1].value,
url: node.children[0].url || node.children[1].url,
depth: node.depth,
})
})
}