2021-08-06 22:13:30 +08:00
|
|
|
import visit from 'unist-util-visit'
|
|
|
|
|
|
|
|
module.exports = function (options) {
|
|
|
|
return (tree) =>
|
|
|
|
visit(tree, 'heading', (node, index, parent) => {
|
|
|
|
options.exportRef.push({
|
2021-08-09 13:57:12 +03:00
|
|
|
value: node.children[0].value || node.children[1].value,
|
|
|
|
url: node.children[0].url || node.children[1].url,
|
2021-08-06 22:13:30 +08:00
|
|
|
depth: node.depth,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|