From 2393a8ac66143d72e611c4fe83009ef52a9c88ab Mon Sep 17 00:00:00 2001 From: Paul de Raaij Date: Fri, 19 Jul 2024 21:53:58 +0200 Subject: [PATCH 1/2] Exclude workspace when linking to a file --- .../src/features/preview/wikilink-navigation.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/foam-vscode/src/features/preview/wikilink-navigation.ts b/packages/foam-vscode/src/features/preview/wikilink-navigation.ts index 14bf04eb1..83a53dcb9 100644 --- a/packages/foam-vscode/src/features/preview/wikilink-navigation.ts +++ b/packages/foam-vscode/src/features/preview/wikilink-navigation.ts @@ -42,17 +42,12 @@ export const markdownItWikilinkNavigation = ( return getPlaceholderLink(label); } - const resourceLabel = isEmpty(alias) - ? `${resource.title}${formattedSection}` - : alias; - const resourceLink = `/${vscode.workspace.asRelativePath( - toVsCodeUri(resource.uri) - )}`; - return getResourceLink( - `${resource.title}${formattedSection}`, - `${resourceLink}${linkSection}`, - resourceLabel - ); + const link = `${vscode.workspace.asRelativePath( + toVsCodeUri(resource.uri), + false + )}${formattedSection}`; + const title = `${resource.title}${formattedSection}`; + return `${label}`; } catch (e) { Logger.error( `Error while creating link for [[${wikilink}]] in Preview panel`, From 72d55f9868fd5a22e2aef116c9bb4026048227e8 Mon Sep 17 00:00:00 2001 From: Paul de Raaij Date: Fri, 19 Jul 2024 21:56:48 +0200 Subject: [PATCH 2/2] Exclude workspace when linking to a file --- .../src/features/preview/wikilink-navigation.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/foam-vscode/src/features/preview/wikilink-navigation.ts b/packages/foam-vscode/src/features/preview/wikilink-navigation.ts index 83a53dcb9..7e85aab8d 100644 --- a/packages/foam-vscode/src/features/preview/wikilink-navigation.ts +++ b/packages/foam-vscode/src/features/preview/wikilink-navigation.ts @@ -42,12 +42,18 @@ export const markdownItWikilinkNavigation = ( return getPlaceholderLink(label); } - const link = `${vscode.workspace.asRelativePath( + const resourceLabel = isEmpty(alias) + ? `${resource.title}${formattedSection}` + : alias; + const resourceLink = `/${vscode.workspace.asRelativePath( toVsCodeUri(resource.uri), false - )}${formattedSection}`; - const title = `${resource.title}${formattedSection}`; - return `${label}`; + )}`; + return getResourceLink( + `${resource.title}${formattedSection}`, + `${resourceLink}${linkSection}`, + resourceLabel + ); } catch (e) { Logger.error( `Error while creating link for [[${wikilink}]] in Preview panel`,