Skip to content

Commit

Permalink
fix(gatsby-transformer-remark): Don't produce invalid AST in TOC(#17080)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst authored and wardpeet committed Sep 2, 2019
1 parent 9aba647 commit 6ba39ad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,14 @@ Object {
"frontmatter": Object {
"title": "my little pony",
},
"tableOfContents": null,
"tableOfContents": "<ul>
<li>
<p></p>
<ul>
<li></li>
</ul>
</li>
</ul>",
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ const bootstrapTest = (
additionalParameters,
pluginOptions,
}).then(result => {
if (result.errors) {
done.fail(result.errors)
}

try {
test(result.data.listNode[0])
done()
Expand Down Expand Up @@ -882,7 +886,6 @@ some other text
node => {
expect(node).toMatchSnapshot()
expect(console.warn).toBeCalled()
expect(node.tableOfContents).toBe(null)
}
)

Expand Down
4 changes: 3 additions & 1 deletion packages/gatsby-transformer-remark/src/extend-node-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ module.exports = (
.replace(/\/\//g, `/`)
}
if (node.children) {
node.children = node.children.map(node => addSlugToUrl(node))
node.children = node.children
.map(node => addSlugToUrl(node))
.filter(Boolean)
}

return node
Expand Down

0 comments on commit 6ba39ad

Please sign in to comment.