fix(utils): do not resolve Markdown paths with @site prefix (#6489)

This commit is contained in:
Joshua Chen 2022-01-28 10:10:39 +08:00 committed by GitHub
parent 8a912c708e
commit 556f59b193
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 1 deletions

View file

@ -30,6 +30,7 @@ describe('replaceMarkdownLinks', () => {
[http](http://github.com/facebook/docusaurus/README.md)
[https](https://github.com/facebook/docusaurus/README.md)
[asset](./foo.js)
[asset as well](@site/docs/_partial.md)
[looks like http...](http.foo.md)
[nonexistent](hmmm.md)
`,
@ -53,6 +54,7 @@ describe('replaceMarkdownLinks', () => {
[http](http://github.com/facebook/docusaurus/README.md)
[https](https://github.com/facebook/docusaurus/README.md)
[asset](./foo.js)
[asset as well](@site/docs/_partial.md)
[looks like http...](/doc/http)
[nonexistent](hmmm.md)
",

View file

@ -65,7 +65,7 @@ export function replaceMarkdownLinks<T extends ContentPaths>({
// This is [Document 1](doc1.md) -> we replace this doc1.md with correct link
// [doc1]: doc1.md -> we replace this doc1.md with correct link
const mdRegex =
/(?:(?:\]\()|(?:\]:\s?))(?!https?:\/\/)([^'")\]\s>]+\.mdx?)/g;
/(?:(?:\]\()|(?:\]:\s?))(?!https?:\/\/|@site\/)([^'")\]\s>]+\.mdx?)/g;
let mdMatch = mdRegex.exec(modifiedLine);
while (mdMatch !== null) {
// Replace it to correct html link.