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