Skip to content

Commit

Permalink
Exclude workspace when linking to a file
Browse files Browse the repository at this point in the history
  • Loading branch information
pderaaij committed Jul 19, 2024
1 parent 2393a8a commit 72d55f9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/foam-vscode/src/features/preview/wikilink-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<a class='foam-note-link' title='${title}' href='/${link}' data-href='/${link}'>${label}</a>`;
)}`;
return getResourceLink(
`${resource.title}${formattedSection}`,
`${resourceLink}${linkSection}`,
resourceLabel
);
} catch (e) {
Logger.error(
`Error while creating link for [[${wikilink}]] in Preview panel`,
Expand Down

0 comments on commit 72d55f9

Please sign in to comment.