Skip to content

Commit

Permalink
fix(v2): properly process multiple nodes in slugger
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 committed Mar 21, 2020
1 parent 79a3f35 commit c7101e0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/docusaurus-mdx-loader/src/remark/slug/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ function slug() {
if (id) {
id = slugs.slug(id, true);
} else {
const headingTextNodes =
headingNode.children.find(
({type}) => !['html', 'jsx'].includes(type),
) || headingNode;
id = slugs.slug(toString(headingTextNodes));
const headingTextNodes = headingNode.children.filter(
({type}) => !['html', 'jsx'].includes(type),
);
const normalizedHeadingNode =
headingTextNodes.length > 0
? {children: headingTextNodes}
: headingNode;
id = slugs.slug(toString(normalizedHeadingNode));
}

data.id = id;
Expand Down

0 comments on commit c7101e0

Please sign in to comment.