Add rehype-mdx-toc to export toc into MDX module#203
Conversation
Signed-off-by: boning-w <wang.boning@outlook.com>
Signed-off-by: boning-w <wang.boning@outlook.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #203 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 154 163 +9
=========================================
+ Hits 154 163 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ChristianMurphy
left a comment
There was a problem hiding this comment.
Thanks for sharing @boning-w!
Some suggestions:
- Consider widening dependencies to
x.0.0to allow npm (and packageme manager friends) to de-duplicate the dependencies as much as possible https://github.com/boning-w/rehype-mdx-toc/blob/f1cc7f1ad5a8573bfcd87ca82fc2133f5c6f17a6/package.json#L47-L51 - What is the intent of
defaultthe option? Could it be made more specific thanunknown? https://github.com/boning-w/rehype-mdx-toc/blob/f1cc7f1ad5a8573bfcd87ca82fc2133f5c6f17a6/src/index.ts#L38 - It is recommended to have a lint checker, whether that be prettier, xo, standard, or a custom ESLint config https://github.com/boning-w/rehype-mdx-toc/blob/f1cc7f1ad5a8573bfcd87ca82fc2133f5c6f17a6/package.json#L43
- These options should not be needed in
nodenextmodule mode https://github.com/boning-w/rehype-mdx-toc/blob/f1cc7f1ad5a8573bfcd87ca82fc2133f5c6f17a6/tsconfig.json#L23-L24 - avoid skipping libcheck, it can hide upstream issues that may impact your users https://github.com/boning-w/rehype-mdx-toc/blob/f1cc7f1ad5a8573bfcd87ca82fc2133f5c6f17a6/tsconfig.json#L38
|
Hi @ChristianMurphy, I really appreciate for your code review.
Regarding:
The I commited these changes and published a new version |
|
Thanks! Your plugin looks really cool! I just don’t think this is the right place to list it. None of the MDX specific plugins are listed in the rehype or remark plugin lists. A better place would be https://mdxjs.com/docs/extending-mdx/#list-of-plugins. |
|
Got it! I may create a pull request there. Should I cloes this pull request? |
|
Let’s have another maintainer close it if they agree with me. :) |
|
I agree it should be listed as a mdx specified plugin instead. |
|
I’ll close this here. Yes, please do add it there! Thanks everyone! |
Initial checklist
Description of changes
I wrote a rehype plugin rehype-mdx-toc that allows users to export the table of contents (TOC) data as a named export from an MDX module.
Why another table of contents plugin?
Since MDX supports exporting data from MDX modules, it's much more convinent to export the TOC — so that users can use it whatever they like, just like with remark-mdx-frontmatter.
Simple usage:
With some bundlers — like @mdx-js/esbuild, @mdx-js/rollup, and @mdx-js/loader, we can easily import the TOC data at build time: