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:
Refactored run, compile, mdx, astProcessor into their own files under ./lib
🧰 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