Skip to content

obsidian/metadata-cache

This module provides utility functions for working with the metadata cache in Obsidian.

InterfaceDescription
CachedMetadataExAn extended CachedMetadata that records which parsing CachedMetadataExFeatures were applied (via CachedMetadataEx.features) and carries the resulting external links. Each links array is populated only when its corresponding feature is present in CachedMetadataEx.features.
GetBacklinksForFileSafeOptionsOptions for getBacklinksForFileSafe.
GetBacklinksForFileSafeParamsParameters for getBacklinksForFileSafe.
GetBacklinksForFileSafeWrapperWrapper for the getBacklinksForFile method that provides a safe overload.
GetLinksParamsParams for getLinks.
ParseCacheOptionsOptions for the parsing performed by getCacheSafe and parseMetadata beyond Obsidian’s native metadata parsing. Each option is opt-in; enabling it adds the corresponding CachedMetadataExFeature and populates the matching links array.
RegisterFileCacheForNonExistingFileParamsParameters for registerFileCacheForNonExistingFile.
FunctionDescription
ensureMetadataCacheReadyEnsures that the metadata cache is ready for all files.
getBacklinksForFileOrPathRetrieves the backlinks for a file or path. NOTE: The file may be non-existent.
getBacklinksForFileSafeRetrieves the backlinks for a file safely.
getCacheSafeRetrieves the cached metadata for a given file or path.
getFrontmatterSafeRetrieves the front matter from the metadata cache safely.
getLinksRetrieves the selected links from the provided cache.
isCachedMetadataExDetermines whether a cache is a CachedMetadataEx (i.e. it was computed with external-link parsing enabled).
parseMetadataParses the metadata for a given string.
registerFileCacheForNonExistingFileRegisters the file cache for a non-existing file.
registerFilesRegisters files in the Obsidian app.
unregisterFileCacheForNonExistingFileUnregisters the file cache for a non-existing file.
unregisterFilesUnregisters files from the Obsidian app.
TypeDescription
GetCacheSafeOptionsOptions for getCacheSafe.
ParseMetadataOptionsOptions for parseMetadata.
EnumDescription
CachedMetadataExFeatureA parsing feature that was applied when computing a CachedMetadataEx.