-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat: mdx TOC #883
Conversation
The failing snapshot is the flaky embed one |
@Rafe this is really ready for review |
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 <rafegoldberg@gmail.com>
This PR was released!🚀 Changes included in v6.75.0-beta.48 |
🧰 Changes
TOC!!1!1
The old TOC worked by parsing the
mdast
forheading
viamdast-util-toc
. This produces anmdast
suitable for rendering via theTableOfContents
component. The packageremark-slug
appears to be abandoned, and the mdx maintainers recommend usingrehype-slug
andrehype-extract-oc
.rehype-extract-toc
generates 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 thecompile
step. Then it can be rendered in theTableOfContents
during therun
step. 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
,astProcessor
into their own files under./lib
Style
component.execute
test helper.🧬 QA & Testing