Skip to content

Commit

Permalink
dont create backlinks that reference itself
Browse files Browse the repository at this point in the history
  • Loading branch information
jparkerweb committed Oct 12, 2024
1 parent e8284fd commit f5065ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 8 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down

0 comments on commit f5065ac

Please sign in to comment.