Cherry.Content.Frontmatter (cherry v0.4.1)

Copy Markdown View Source

Splits and parses YAML frontmatter fenced by --- lines.

YAML because it is what the whole SSG ecosystem writes — humans and agents both already know it. Keys stay strings here; they are matched against a collection's schema keys during validation, so no unknown atoms are ever created from user content.

Summary

Functions

Splits a file into {frontmatter_map, body}.

Functions

parse(content)

@spec parse(String.t()) :: {:ok, map() | nil, String.t()} | {:error, String.t()}

Splits a file into {frontmatter_map, body}.

Returns {:ok, nil, content} when the file has no frontmatter fence — callers decide whether bare files are allowed in their collection.