Backlinks

Overview

Backlinks are used to navigate note links in the other direction.

Backlinks are initialized during workspace init. See workspace init for more details.

The backlinks are not later kept up-to-date as notes change, because it's expensive to update them. Instead, they get recalculated on the run by BacklinksTreeDataProvider when needed. The view itself might need to get refreshed however, which you can do by using getExtension().backlinksTreeDataProvider?.refresh(). See FileWatcher.refreshTree for an example.

Lifecycle

getChildren(backlink) {
	if (!backlink) return pathsToBacklinkSourceTreeItems
	...
}

pathsToBacklinkSourceTreeItems(fsPath) {
	fileName := fsPath
	findReferences(fileName)

}
findReferences(fname) {

	notes = getNotesByFname(fname)
	notes.map n => { getNotesWithLinkTo(n) }
}
getNotesWithLinkTo(note, allNotes) {
	return allNotes.filter n => {
		find(n.links, l => l.to = note.fname
	}
}

Common Issues

First thing to check is that the links themselves are being updated. NoteUtils.updateNoteMetadata is responsible for finding the links after initialization, make sure it's finding the right links.

For files added outside of Dendron (git sync, file copied etc.), FileWatcher is responsible for updating notes. It also refreshes the tree and backlink views. Make sure these are functioning correctly.


Backlinks