Documentation
¶
Index ¶
- Variables
- func Decode(content []byte, decode func([]byte) error) (string, error)
- func Format[T any](metadata T, body string) (string, error)
- func RewriteStringField(content string, key string, value string) (string, error)
- func RewriteStringValues(content []byte, rewrite func(string) string) ([]byte, int, error)
- func UnmarshalMetadata(metadata []byte, target any) error
- type Parts
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrMissing reports content that does not start with a valid YAML frontmatter block. ErrMissing = errors.New("frontmatter: missing YAML frontmatter") // ErrUnterminated reports content whose opening delimiter has no matching closing delimiter. ErrUnterminated = errors.New("frontmatter: unterminated YAML frontmatter") // ErrBOM reports content that starts with a UTF-8 BOM before the YAML frontmatter delimiter. ErrBOM = errors.New("frontmatter: UTF-8 BOM before YAML frontmatter") )
Functions ¶
func Format ¶
Format serializes metadata and a Markdown body using the canonical frontmatter byte shape.
func RewriteStringField ¶
RewriteStringField updates one top-level scalar without reserializing the surrounding document.
func RewriteStringValues ¶
RewriteStringValues changes metadata values while preserving comments, keys, and the Markdown body.
func UnmarshalMetadata ¶
UnmarshalMetadata decodes YAML metadata without exposing the YAML dependency to callers that only need the shared frontmatter parser.
Types ¶
Click to show internal directories.
Click to hide internal directories.