egoist / docute

📚 Effortless documentation, done right.
https://docute.egoist.dev
MIT License
3.8k stars 427 forks source link

Convert markdown links to router-link #161

Closed egoist closed 5 years ago

egoist commented 6 years ago

If you use <router-link> component in the markdown it will be broken on GitHub since GitHub does not allow HTML and Vue template (obviously).

Links like [/docs/foo.md](/docs/foo.md) will be converted to corresponding links on GitHub, so it would be nice if Docute can convert it to corresponding link too using <router-link> instead of <a>.

The question is what kind of links should be converted, I think relative/absolute path ending with .md, like /^\.?\/.+\.md$/ would be fine. If you don't want certain markdown link to be converted, use HTML <a> tag instead.


Example:

[foo](/website/docs/foo.md)

On GitHub:

<a href="PATH/blob/master/website/docs/foo.md">foo</a>

On Docute:

<router-link to="/website/docs/foo">foo</router-link>

But obviously on Docute the link should be: /docs/foo instead since we served ./website as root directory. An option like removeLinkPrefix: '/website' might be necessary then.