Skip to content

getFrontmatterSafe<CustomFrontmatter = unknown>

Retrieves the front matter from the metadata cache safely.

It reads through getCacheSafe, so it saves any open editor view of the note that has unsaved changes. See getCacheSafe for when that save matters and what to use instead.

Import:

import { getFrontmatterSafe } from '@mnaoumov/obsidian-lib/metadata-cache';

Signature:

function getFrontmatterSafe(app: App, pathOrFile: PathOrFile): Promise<CombinedFrontmatter<CustomFrontmatter>>

Parameters:

Parameter Type Description
app App The Obsidian app instance.
pathOrFile PathOrFile The path or file to retrieve the front matter from.

Returns: Promise<CombinedFrontmatter<CustomFrontmatter>> — The combined front matter.