Skip to content

Commit 09eded2

Browse files
Merge pull request #117 from replayio/aditya/add-link-to-heading
2 parents 81a602d + 92a3143 commit 09eded2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/markdoc/nodes.mjs

+3-5
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ const nodes = {
4141
let text = children.filter((child) => typeof child === 'string').join(' ')
4242
let id = attributes.id ?? slugify(text)
4343

44-
return new Tag(
45-
`h${node.attributes.level}`,
46-
{ ...attributes, id },
47-
children,
48-
)
44+
return new Tag(`a`, { href: `#${id}`, ...attributes }, [
45+
new Tag(`h${node.attributes.level}`, { id }, children),
46+
])
4947
},
5048
},
5149
th: {

0 commit comments

Comments
 (0)