upstream #1

Merged
jblu merged 1007 commits from upstream into main 2024-11-04 22:35:57 -06:00
Showing only changes of commit cd754b5de3 - Show all commits

View File

@ -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,
}) })
}) })