mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-05 04:12:53 +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) {
|
if (id) {
|
||||||
id = slugs.slug(id, true);
|
id = slugs.slug(id, true);
|
||||||
} else {
|
} else {
|
||||||
const headingTextNodes =
|
const headingTextNodes = headingNode.children.filter(
|
||||||
headingNode.children.find(
|
({type}) => !['html', 'jsx'].includes(type),
|
||||||
({type}) => !['html', 'jsx'].includes(type),
|
);
|
||||||
) || headingNode;
|
const normalizedHeadingNode =
|
||||||
id = slugs.slug(toString(headingTextNodes));
|
headingTextNodes.length > 0
|
||||||
|
? {children: headingTextNodes}
|
||||||
|
: headingNode;
|
||||||
|
id = slugs.slug(toString(normalizedHeadingNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
data.id = id;
|
data.id = id;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue