MetadataCache

MetadataCache class

Linktext is any internal link that is composed of a path and a subpath, such as ‘My note#Heading’ Linkpath (or path) is the path part of a linktext Subpath is the heading/block ID part of a linktext.

Signature:

export class MetadataCache extends Events 

Extends: Events

Properties

PropertyModifiersTypeDescription
resolvedLinksRecord<string, Record<string, number>>Contains all resolved links. This object maps each source file’s path to an object of destination file paths with the link count. Source and destination paths are all vault absolute paths that comes from TFile.path and can be used with Vault.getAbstractFileByPath(path).
unresolvedLinksRecord<string, Record<string, number>>Contains all unresolved links. This object maps each source file to an object of unknown destinations with count. Source paths are all vault absolute paths, similar to resolvedLinks.

Methods

MethodModifiersDescription
fileToLinktext(file, sourcePath, omitMdExtension)

Generates a linktext for a file.

If file name is unique, use the filename. If not unique, use full path.

getCache(path)
getFileCache(file)
getFirstLinkpathDest(linkpath, sourcePath)Get the best match for a linkpath.
off(name, callback)

(Inherited from Events)

offref(ref)

(Inherited from Events)

on(name: 'changed', callback, ctx)

Called when a file has been indexed, and its (updated) cache is now available.

Note: This is not called when a file is renamed for performance reasons. You must hook the vault rename event for those.

on(name: 'deleted', callback, ctx)Called when a file has been deleted. A best-effort previous version of the cached metadata is presented, but it could be null in case the file was not successfully cached previously.
on(name: 'resolve', callback, ctx)Called when a file has been resolved for resolvedLinks and unresolvedLinks. This happens sometimes after a file has been indexed.
on(name: 'resolved', callback, ctx)Called when all files has been resolved. This will be fired each time files get modified after the initial load.
trigger(name, data)

(Inherited from Events)

tryTrigger(evt, args)

(Inherited from Events)