generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Labels
Description
I have been using this plugin in for a while, but decided that I wanted to move to Markdown links instead of Wikilinks. This broke this plugin. Since this plugin does not seem to have been updated for a while, I have not created a PR.
However, I have modified the main.js file (with the help of ChatGPT). Replace the getLinkFile with this one. It seems to work in my instance, but your mileage may vary...
getLinkFile(link) {
const markdownFiles = this.app.vault.getMarkdownFiles();
// 1. Decode URL-encoded characters (e.g. %20)
let linkPath = decodeURIComponent(link.link);
// 2. Remove .md extension if present
if (linkPath.toLowerCase().endsWith(".md")) {
linkPath = linkPath.slice(0, -3);
}
// 3. Normalise path (Obsidian paths never start with '/')
linkPath = linkPath.replace(/^\/+/, "");
return markdownFiles.find(f =>
// Exact path match (folder/note)
f.path === `${linkPath}.md` ||
// Match by filename only (wikilinks without folder)
f.path.endsWith(`/${linkPath}.md`) ||
// Match root-level notes
f.name === `${linkPath}.md`
);
}
From what I can see, the difference in the links between WikiLinks and Markdown lists are two fold. Markdown links:
- are URL encoded, ie spaces become %32
- have
.mdat the end oflink.link
The change to the above function addresses both of these, while still working with Wikilinks.