getBacklinksForFileSafe
Retrieves the backlinks for a file safely.
When Advanced Metadata Cache publishes its backlinks API and its Backlinks module is on, that API answers.
Otherwise this is NOT a pure read. It verifies each backlink against the note’s current text, and to do that it calls saveNote on every note that links to the file, which saves any open editor view of those notes that has unsaved changes. Call it from an explicit user action. Do not call it from an automatic trigger (a vault or metadata event, a save or render patch) that only decides whether to act. There, a forced save can race another plugin’s in-flight editor change.
Import:
import { getBacklinksForFileSafe } from '@mnaoumov/obsidian-lib/metadata-cache';Signature:
function getBacklinksForFileSafe(params: GetBacklinksForFileSafeParams): Promise<CustomArrayDict<Reference>>Parameters:
| Parameter | Type | Description |
|---|---|---|
params |
GetBacklinksForFileSafeParams | The parameters for retrieving the backlinks. |
Returns: Promise<CustomArrayDict<Reference>> — A Promise that resolves to an array dictionary of backlinks.
Links to this page: