readmeio / markdown

ReadMe's flavored Markdown parser and React-based rendering engine.
https://rdmd.readme.io
ISC License
34 stars 9 forks source link

feat: mdx TOC #883

Closed kellyjosephprice closed 5 months ago

kellyjosephprice commented 5 months ago
PR App Fix RM-9179

🧰 Changes

TOC!!1!1

The old TOC worked by parsing the mdast for heading via mdast-util-toc. This produces an mdast suitable for rendering via the TableOfContents component. The package remark-slug appears to be abandoned, and the mdx maintainers recommend using rehype-slug and rehype-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 components hast's during the compile step. Then it can be rendered in the TableOfContents during the run 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:

🧬 QA & Testing

kellyjosephprice commented 5 months ago

The failing snapshot is the flaky embed one

kellyjosephprice commented 5 months ago

@rafe this is really ready for review

rafegoldberg commented 5 months ago

This PR was released!

🚀 Changes included in v6.75.0-beta.48