From 975bfc89e843b4e1fd60dde82372247d5a7b9c17 Mon Sep 17 00:00:00 2001 From: Linc <762699299@qq.com> Date: Sun, 1 Dec 2024 09:16:55 +0000 Subject: [PATCH 1/4] fix(bi-link): isRelativePath invalid in windows --- .../src/index.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/markdown-it-bi-directional-links/src/index.ts b/packages/markdown-it-bi-directional-links/src/index.ts index ba5138c8..8a2fa4b3 100644 --- a/packages/markdown-it-bi-directional-links/src/index.ts +++ b/packages/markdown-it-bi-directional-links/src/index.ts @@ -355,9 +355,20 @@ export const BiDirectionalLinks: (options?: BiDirectionalLinksOptions) => Plugin let resolvedNewHref: string if (isRelativePath) { - resolvedNewHref = relative(dirname(state.env.relativePath), matchedHref) - .split(sep) - .join('/') + if (state.env.relativePath) { // linux + resolvedNewHref = relative(dirname(state.env.relativePath), matchedHref) + .split(sep) + .join('/') + } + else if (state.env.filePathRelative) { // windows + resolvedNewHref = relative(dirname(state.env.filePathRelative), matchedHref) + .split(sep) + .join('/') + } + else { // other + console.error('Can\'t find local file path') + return false + } } else { resolvedNewHref = posix.join( From 8192c641f147959d1bf5b400093a6128bfbdb51a Mon Sep 17 00:00:00 2001 From: Linc <762699299@qq.com> Date: Fri, 6 Dec 2024 17:57:18 +0800 Subject: [PATCH 2/4] fix(bi-link): comment error --- packages/markdown-it-bi-directional-links/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/markdown-it-bi-directional-links/src/index.ts b/packages/markdown-it-bi-directional-links/src/index.ts index 8a2fa4b3..cc2feb52 100644 --- a/packages/markdown-it-bi-directional-links/src/index.ts +++ b/packages/markdown-it-bi-directional-links/src/index.ts @@ -355,12 +355,12 @@ export const BiDirectionalLinks: (options?: BiDirectionalLinksOptions) => Plugin let resolvedNewHref: string if (isRelativePath) { - if (state.env.relativePath) { // linux + if (state.env.relativePath) { // VitePress resolvedNewHref = relative(dirname(state.env.relativePath), matchedHref) .split(sep) .join('/') } - else if (state.env.filePathRelative) { // windows + else if (state.env.filePathRelative) { // VuePress resolvedNewHref = relative(dirname(state.env.filePathRelative), matchedHref) .split(sep) .join('/') From a1f575185372b9758ea4f30f14c15ad8a5e13d0e Mon Sep 17 00:00:00 2001 From: Linc <762699299@qq.com> Date: Wed, 18 Dec 2024 11:54:48 +0800 Subject: [PATCH 3/4] chore(bi-link): add some comment --- packages/markdown-it-bi-directional-links/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/markdown-it-bi-directional-links/src/index.ts b/packages/markdown-it-bi-directional-links/src/index.ts index cc2feb52..7ddf4c9c 100644 --- a/packages/markdown-it-bi-directional-links/src/index.ts +++ b/packages/markdown-it-bi-directional-links/src/index.ts @@ -360,7 +360,7 @@ export const BiDirectionalLinks: (options?: BiDirectionalLinksOptions) => Plugin .split(sep) .join('/') } - else if (state.env.filePathRelative) { // VuePress + else if (state.env.filePathRelative) { // VuePress, see [#361](nolebase/integrations/pull/361) for details resolvedNewHref = relative(dirname(state.env.filePathRelative), matchedHref) .split(sep) .join('/') From a1569b6accd781213eb2aafcf21c0d68da46b5a0 Mon Sep 17 00:00:00 2001 From: Neko Date: Thu, 19 Dec 2024 13:51:28 +0800 Subject: [PATCH 4/4] chore: update index.ts --- packages/markdown-it-bi-directional-links/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/markdown-it-bi-directional-links/src/index.ts b/packages/markdown-it-bi-directional-links/src/index.ts index 7ddf4c9c..b0be0984 100644 --- a/packages/markdown-it-bi-directional-links/src/index.ts +++ b/packages/markdown-it-bi-directional-links/src/index.ts @@ -360,7 +360,7 @@ export const BiDirectionalLinks: (options?: BiDirectionalLinksOptions) => Plugin .split(sep) .join('/') } - else if (state.env.filePathRelative) { // VuePress, see [#361](nolebase/integrations/pull/361) for details + else if (state.env.filePathRelative) { // VuePress, see https://github.com/nolebase/integrations/pull/361 for details resolvedNewHref = relative(dirname(state.env.filePathRelative), matchedHref) .split(sep) .join('/')