From 164a2e2004c2b907f912a1260dc071cda751e9d1 Mon Sep 17 00:00:00 2001 From: Havin Leung Date: Thu, 30 Jun 2022 21:04:34 -0400 Subject: [PATCH] actually fix the links this time --- main.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/main.ts b/main.ts index d6eff20..07daf90 100644 --- a/main.ts +++ b/main.ts @@ -147,10 +147,9 @@ export default class Waypoint extends Plugin { * @returns The string representation of the tree, or null if the node is not a file or folder */ async getFileTreeRepresentation(root_node: TFolder, cur_node: TAbstractFile, indentLevel: number, topLevel = false): Promise|null { - let pathFromRootNode = function() { - let prefix_len = root_node.path.length; - let link = cur_node.path.substring(prefix_len); - return `./${encodeURI(link)}` + let pathFromRootNode = function(node: TAbstractFile) { + let prefix_len = root_node.path.length + 1; + return `./${encodeURI(node.path.substring(prefix_len))}`; }; const bullet = " ".repeat(indentLevel) + "-"; if (cur_node instanceof TFile) { @@ -158,7 +157,7 @@ export default class Waypoint extends Plugin { if (this.settings.useWikiLinks) { return `${bullet} [[${cur_node.basename}]]`; } else { - return `${bullet} [${cur_node.basename}](${pathFromRootNode()})`; + return `${bullet} [${cur_node.basename}](${pathFromRootNode(cur_node)})`; } } return null; @@ -169,7 +168,7 @@ export default class Waypoint extends Plugin { if (this.settings.useWikiLinks) { text = `${bullet} **[[${folderNote.basename}]]**`; } else { - text = `${bullet} **[${folderNote.basename}](./${pathFromRootNode()})**`; + text = `${bullet} **[${folderNote.basename}](${pathFromRootNode(folderNote)})**`; } if (!topLevel) { if (this.settings.stopScanAtFolderNotes) {