From f5065accbea151d7c0376d5476c10049938624cf Mon Sep 17 00:00:00 2001 From: Justin Parker Date: Fri, 11 Oct 2024 21:49:00 -0700 Subject: [PATCH] dont create backlinks that reference itself --- manifest.json | 2 +- src/main.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index b793c94..113a728 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "rich-foot", "name": "Rich Foot", - "version": "1.1.0", + "version": "1.2.0", "minAppVersion": "0.12.0", "description": "Adds backlink tags and created/modified dates to the footer of your notes.", "author": "Justin Parker", diff --git a/src/main.js b/src/main.js index 884cda9..b3ffd09 100644 --- a/src/main.js +++ b/src/main.js @@ -113,6 +113,9 @@ class RichFootPlugin extends Plugin { const backlinksUl = backlinksDiv.createEl('ul'); for (const [linkPath, backlinks] of Object.entries(backlinkList.data)) { + // Skip if the linkPath is the same as the current file's path + if (linkPath === file.path) continue; + if (this.shouldIncludeBacklink(linkPath)) { const parts = linkPath.split('/'); const displayName = parts[parts.length - 1].slice(0, -3); // Remove '.md' @@ -128,6 +131,11 @@ class RichFootPlugin extends Plugin { }); } } + + // Only add the backlinks div if there are actually backlinks + if (backlinksUl.childElementCount === 0) { + backlinksDiv.remove(); + } } // Modified date