vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.35k stars 923 forks source link

[Feature request] Provide isExternal options for `markdown.links` #1611

Closed Mister-Hope closed 1 month ago

Mister-Hope commented 1 month ago

Clear and concise description of the problem

In some cases, people may want to deploy multiple VuePress sites (or sites generated by other tools) in one directly.

For example:

In this case, any links that is under /api/ should be marked external, however, the linksPlugin uses isLinkExternal from @vuepress/shared directly here:

https://github.com/vuepress/core/blob/eaa97e6f5057861c79ce275432d0de61c962c1c5/packages/markdown/src/plugins/linksPlugin/linksPlugin.ts#L76

Suggested solution

Provide a isExternal option:

isExternal: (link: string, env: MarkdownEnv) => boolean

We can also use other formats, but it must expose base filePathRelative variables so that users can "resolve" final path to make a further judgement if necessary.

Alternative

No response

Additional context

No response