fix: insert code title relative to parent
This commit is contained in:
parent
2ccdc25819
commit
ff2362fca4
@ -2,7 +2,7 @@ import { visit } from 'unist-util-visit'
|
||||
|
||||
export default function remarkCodeTitles() {
|
||||
return (tree) =>
|
||||
visit(tree, 'code', (node, index) => {
|
||||
visit(tree, 'code', (node, index, parent) => {
|
||||
const nodeLang = node.lang || ''
|
||||
let language = ''
|
||||
let title = ''
|
||||
@ -26,7 +26,7 @@ export default function remarkCodeTitles() {
|
||||
data: { _xdmExplicitJsx: true },
|
||||
}
|
||||
|
||||
tree.children.splice(index, 0, titleNode)
|
||||
parent.children.splice(index, 0, titleNode)
|
||||
node.lang = language
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user