-
Notifications
You must be signed in to change notification settings - Fork 15
feat: mdx TOC #883
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
feat: mdx TOC #883
Conversation
|
The failing snapshot is the flaky embed one |
|
@Rafe this is really ready for review |
rafegoldberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a couple more suggestions, but this worked great when I tested locally! 🤘 And like I said, I appreciate the code cleanup herein!
| ``` | ||
| ###A Valid Heading | ||
| Lorem ipsum dolor etc. | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Not to be picky since I know this isn't technically within the scope of this PR, but I did notice that this compact header notation isn't working with the new MDX processor!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
components/Heading/index.tsx
Outdated
| </div> | ||
| <a | ||
| key={`heading-anchor-icon-${id}`} | ||
| aria-label={`Skip link to ${children[1]}`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this children[1] logic still makes sense now that we're getting rid of the showAnchorIcons option?1
Maybe it should just be:
aria-label={`Skip link to ${children}`}Footnotes
-
side note: why are we getting rid of this? is it just not used anywhere? ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see it used anywhere, so I didn't bother porting it?
Co-authored-by: Rafe Goldberg <[email protected]>
This PR was released!🚀 Changes included in v6.75.0-beta.48 |

🧰 Changes
TOC!!1!1
The old TOC worked by parsing the
mdastforheadingviamdast-util-toc. This produces anmdastsuitable for rendering via theTableOfContentscomponent. The packageremark-slugappears to be abandoned, and the mdx maintainers recommend usingrehype-slugandrehype-extract-oc.rehype-extract-tocgenerates a POJO that represent the TOC, and it doesn't appear to have any functions for parsing component imports. So, I've implemented a plugin that parses the main doc and it's componentshast's during thecompilestep. Then it can be rendered in theTableOfContentsduring therunstep. This changes the return signatures to be an object instead of a single component, to prevent requiring 2 separate compile and run steps when rendering.Other notable changes:
run,compile,mdx,astProcessorinto their own files under./libStylecomponent.executetest helper.🧬 QA & Testing