summaryrefslogtreecommitdiff
path: root/packages/markdown-support/src/rehype-collect-headers.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/markdown-support/src/rehype-collect-headers.ts')
-rw-r--r--packages/markdown-support/src/rehype-collect-headers.ts4
1 files changed, 3 insertions, 1 deletions
diff --git a/packages/markdown-support/src/rehype-collect-headers.ts b/packages/markdown-support/src/rehype-collect-headers.ts
index edfcd29bc..de9b78692 100644
--- a/packages/markdown-support/src/rehype-collect-headers.ts
+++ b/packages/markdown-support/src/rehype-collect-headers.ts
@@ -14,11 +14,13 @@ export default function createCollectHeaders() {
depth = Number.parseInt(depth);
let text = '';
+
visit(node, 'text', (child) => {
text += child.value;
});
- let slug = slugger.slug(text);
+ let slug = node.properties.id || slugger.slug(text);
+
node.properties = node.properties || {};
node.properties.id = slug;
headers.push({ depth, slug, text });