mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-01 18:32:52 +02:00
fix(v2): properly process multiple nodes in slugger
This commit is contained in:
parent
79a3f35de6
commit
c7101e032b
1 changed files with 8 additions and 5 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue