Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-transformer-remark): Don't produce invalid AST in TOC #17080

Merged
merged 3 commits into from
Sep 2, 2019

Conversation

stefanprobst
Copy link
Contributor

The table of contents generation in gatsby-transformer-remark can produce an invalid AST (when no pathToSlug field is provided, node.children will be a sparse [null] array.

Unrelated: what's the reason pathToSlug is required in the first place?

@stefanprobst stefanprobst requested a review from a team as a code owner August 26, 2019 05:30
@stefanprobst
Copy link
Contributor Author

stefanprobst commented Aug 26, 2019

Also updated test+snapshot -- the test was returning null only because this line actually throws.

@wardpeet
Copy link
Contributor

wardpeet commented Aug 30, 2019

How do I test if this PR works? I've run the example on the bug report but it still fails with

image

@stefanprobst
Copy link
Contributor Author

the example on the bug report but it still fails

yes, see my comment there. this PR only fixes one part, which is the invalid ast produced by the tableOfContents resolver.

I've fixed the transformer-remark test setup with a2b9eb2 , so without this PR one of the tableOfContents tests would now correctly fail.

Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Stefan! Looks good!

Unrelated: what's the reason pathToSlug is required in the first place?

I have no clue on this matter.

@wardpeet wardpeet merged commit 6ba39ad into gatsbyjs:master Sep 2, 2019
@stefanprobst stefanprobst deleted the fix-invalid-ast-again branch September 2, 2019 08:19
waltercruz pushed a commit to waltercruz/gatsby that referenced this pull request Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants