sibiraj-s / marked-react

⚛️ Render Markdown as React components
https://sibiraj-s.github.io/marked-react/
MIT License
70 stars 11 forks source link

Replace html anchors with React Router Link component #19

Closed romatou closed 1 year ago

romatou commented 1 year ago

I was implementing markdown parser in my project and ran into a problem where links with relative paths were redirecting to a page and clearing state (acting as standard anchors) due to page reload. React Router Link component or useNavigate() secures the page reload and keeps the state. I was suggested to use marked-react for this but it didn't solve my problem.

Could you please provide solution for replacing anchors with Link component?

sibiraj-s commented 1 year ago

can you try custom renderer. Example can be found here.

https://github.com/sibiraj-s/marked-react#syntax-highlight-code-blocks

I will add the custom renderer to the Readme as a separate block.