frontmatter

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Ports packages/coding-agent/src/utils/frontmatter.ts.

Package frontmatter parses YAML frontmatter blocks from markdown files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Doc

type Doc struct {
	// Frontmatter holds the YAML values from the document header.
	Frontmatter map[string]any
	// Body is the trimmed markdown content following the closing `---`.
	Body string
	// Err reports malformed YAML. The body remains available to callers that
	// intentionally tolerate malformed frontmatter.
	Err error
}

Doc is a parsed markdown-with-frontmatter file.

func Parse

func Parse(content string) Doc

Parse extracts and parses a YAML frontmatter block plus body. If the file does not begin with a closed frontmatter block, the whole input is returned as Body and Frontmatter is empty.

func (Doc) Bool

func (d Doc) Bool(key string) bool

Bool returns the named field as a bool, defaulting to false.

func (Doc) String

func (d Doc) String(key string) string

String returns the named field as a string, or "" if missing.

func (Doc) StringList

func (d Doc) StringList(key string) []string

StringList returns the named field as a []string, accepting either a list value or a single comma-separated string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL