feat: toc for blog post

This commit is contained in:
Timothy Lin
2021-08-06 22:13:30 +08:00
parent 304318376c
commit afbc2d9c66
7 changed files with 52 additions and 1 deletions

View File

@@ -0,0 +1,12 @@
import visit from 'unist-util-visit'
module.exports = function (options) {
return (tree) =>
visit(tree, 'heading', (node, index, parent) => {
options.exportRef.push({
value: node.children[1].value,
url: node.children[0].url,
depth: node.depth,
})
})
}