Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit aa5288e

Browse files
committed
add h3s as links
1 parent debf94a commit aa5288e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/mdx/rehype.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ function rehypeParseCodeBlocks() {
1919
}
2020
}
2121

22+
const ALLOWED_TAGS = ['h2', 'h3']
23+
2224
function rehypeSlugify() {
2325
return (tree) => {
2426
let slugify = slugifyWithCounter()
2527
visit(tree, 'element', (node) => {
26-
if (node.tagName === 'h2' && !node.properties.id) {
28+
if (ALLOWED_TAGS.includes(node.tagName) && !node.properties.id) {
2729
node.properties.id = slugify(toString(node))
2830
}
2931
})
@@ -103,6 +105,7 @@ export const rehypePlugins = [
103105
[
104106
rehypeAutolinkHeadings,
105107
{
108+
test: ALLOWED_TAGS,
106109
behavior: 'append',
107110
headingProperties: {
108111
className: ['md-content-header group'],

0 commit comments

Comments
 (0)