unplugin / unplugin-vue-markdown

Compile Markdown to Vue component
MIT License
518 stars 28 forks source link

Automatically convert internal links to router links. #37

Closed f3ve closed 9 months ago

f3ve commented 9 months ago

Clear and concise description of the problem

Currently to create an internal link you have to manually write a RouterLink.

This is my markdown

This is an internal <RouterLink to="/example">link</RouterLink>

I would like to write internal links like regular markdown links and have it automatically convert to a RouterLink

This is my markdown

This is an internal [link](/example)

Suggested solution

All links that are only a path: E.G. / or /example/path and don't start with a website url like https://example.com/example/path should be treated like internal links.

In unplugin-vue-markdown options add a internalLinkComponent option, similar to the wrapperComponent option:

Markdown({
  internalLinkComponent: 'RouterLink'
})

This would also allow users to pass a custom router link component

Markdown({
  internalLinkComponent: 'MyCustomRouterLink`
})

Alternative

No response

Additional context

No response

Validations

antfu commented 9 months ago

Sounds good, PR welcome!