vaultmd / parseFrontmatter
Function: parseFrontmatter()
parseFrontmatter(
content):ParsedFrontmatter
Defined in: src/frontmatter/parse.ts:46
Parse the YAML frontmatter from a markdown file's raw content string. Handles files with no frontmatter, empty blocks, invalid YAML, and flat-safe vs. nested-object blocks. Never throws.
Parameters
content
string
Raw UTF-8 content of a markdown file.
Returns
A ParsedFrontmatter with the parsed key-value map, tag tokens, body text, and a FrontmatterValidity descriptor.
Example
ts
const { frontmatter, tags, body, valid } = parseFrontmatter(fileContent);
if (valid === 'flat') { // safe to pass to editFrontmatter }