Skip to content

Commit 09c7af6

Browse files
authored
fix(doc-core): external link normalize (#3689)
1 parent 361204f commit 09c7af6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

.changeset/apple-and-sala.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@modern-js/doc-core': patch
3+
---
4+
5+
fix(doc-core): external link normalize
6+
7+
fix(doc-core): 修复外部链接不规范的问题

packages/cli/doc-core/src/node/runtimeModule/siteData.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
MDX_REGEXP,
2929
SEARCH_INDEX_NAME,
3030
addLeadingSlash,
31+
isExternalUrl,
3132
} from '@/shared/utils';
3233

3334
let pages: PageIndexInfo[] | undefined;
@@ -66,7 +67,12 @@ export function normalizeThemeConfig(
6667
const i18nTextData = getI18nData(docConfig);
6768
// In following code, we will normalize the theme config reference to the pages data extracted from mdx files
6869
const normalizeLangPrefix = (link?: string, currentLang?: string) => {
69-
if (!currentLang || !link || link.startsWith(`/${currentLang}`)) {
70+
if (
71+
!currentLang ||
72+
!link ||
73+
link.startsWith(`/${currentLang}`) ||
74+
isExternalUrl(link)
75+
) {
7076
return link;
7177
}
7278
// if lang exists, we should add the lang prefix to the link

0 commit comments

Comments
 (0)