feat: toc for blog post
This commit is contained in:
12
lib/remark-toc-headings.js
Normal file
12
lib/remark-toc-headings.js
Normal 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,
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user