Skip to content

getFrontMatterInfo

Official

Given the contents of a file, get information about the frontmatter of the file, including whether there is a frontmatter block, the offsets of where it starts and ends, and the frontmatter text.

Import:

import { getFrontMatterInfo } from 'obsidian';

Example:

const content = `---
key1: value1
key2: value2
---
main content
`;
console.log(getFrontMatterInfo(content));

Signature:

function getFrontMatterInfo(content: string): FrontMatterInfo

Parameters:

ParameterTypeDescription
contentstring

Returns: FrontMatterInfo

Example:

const content = `---
key1: value1
key2: value2
---
main content
`;
console.log(getFrontMatterInfo(content));