Created
August 14, 2025 05:30
-
-
Save appendjeff/b5874a4a59e51b913e7740d9a6c17b40 to your computer and use it in GitHub Desktop.
Obsidian x dataview script to display one layer of nested backlinks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```dataviewjs | |
| TODO - replace the following block inside this block | |
| ``` | |
| // Simple backlinks finder | |
| // Change the note name below, or leave empty to use current note | |
| const targetNote = ""; // e.g., "My Note" or leave empty for current note | |
| const noteName = targetNote || dv.current().file.basename; | |
| const backlinks = []; | |
| // Find all pages that link to the target note | |
| for (const page of dv.pages()) { | |
| // Skip the target note itself | |
| if (page.file.basename === noteName) continue; | |
| // Check if this page has outlinks to our target | |
| if (page.file.outlinks && page.file.outlinks.some(link => | |
| link.path.includes(noteName) || link.display === noteName | |
| )) { | |
| backlinks.push(page); | |
| } | |
| } | |
| // Display results | |
| if (backlinks.length === 0) { | |
| dv.paragraph(`No backlinks found for "${noteName}"`); | |
| } else { | |
| dv.header(3, `Backlinks to "${noteName}"`); | |
| dv.list(backlinks.map(p => p.file.link)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment