How do I add html-attributes from my custom rehype
plug-in
#1187
Unanswered
prestonbourne
asked this question in
Q&A
Replies: 1 comment
-
You can use https://github.com/rehypejs/rehype-slug to add IDs to headings. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What I want
To visit heading nodes throughout the tree and apply a custom id to each of them and then push these all these headings into an object that I plan to use elsewhere in the app.
For additional context, if what I'm doing seems strange I'm trying to build a Table of Contents / Page outline similar to what you'd see on google docs or nextra The on this page component on the right handside is my long term goal
What I'm trying
So from what I've read thus far, anything in
node.data.hProperties
should automatically get passed torehype
and then placed in the final rendered mark-up. That led to me to produce this block of code. I've put comments throughout the code to convey my itentionsEdit: I should add that this is being done with Next.js
I'm having the props being passed with this pattern
Beta Was this translation helpful? Give feedback.
All reactions