core
core copied to clipboard
[Bug report] `linksPlugin` cannot correctly identify whether it is an external link.
Description
The linksPlugin does not accurately reflect whether a link is external.
The issue is that the default logic of isExternal simplistically considers links that do not start with base and do not end with .md as external links.
However, this handling is inappropriate. When a site's base is /docs/ and the page is configured with permalink: /guide/foo/, using [foo](/guide/foo/) in markdown will mistakenly be identified as an external link.
In reality, it should concatenate with base and be recognized as an internal link rather than an external one.
/guide/foo.md
---
permalink: /guide/foo/
---
README.md
[jump to /guide/foo/](/guide/foo/)
[jump to ./guide/foo.md](./guide/foo.md)
I believe that the formatting of the two links should be consistent, and that /guide/foo/ should not be treated as an external link.
Solution
I believe the linksPlugin does not need to make unnecessary judgments about whether a link is external or not. It lacks information such as pages -> path, which leads to inaccurate results.
We can fully delegate this functionality to the RouteLink or AutoLink components to handle. With the existence of routes.js, it can help us accurately determine whether a link is external.
Reproduction
https://stackblitz.com/edit/vuepress-vzbywlkp?file=docs%2FREADME.md
Used Package Manager
pnpm
System Info
-