Documentation
¶
Overview ¶
Package jsonyaml provides a MetaLoader that accepts either YAML or JSON frontmatter.
YAML frontmatter is delimited by ---\n ... \n---\n:
--- title: My Post tags: [go, web] --- body content here
JSON frontmatter is a JSON object terminated by a closing }\n on its own line:
{
"title": "My Post",
"tags": ["go", "web"]
}
body content here
YAML is parsed via yamlite (no heavy YAML library dependency).
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Loader = func(raw []byte) (map[string]any, []byte, error) { if bytes.HasPrefix(raw, []byte("---\n")) { return loadYAML(raw) } if bytes.HasPrefix(raw, []byte("{\n")) { return loadJSON(raw) } return map[string]any{}, raw, nil }
Loader parses YAML or JSON frontmatter and returns the metadata and body. Files with no recognized frontmatter prefix are returned as body-only with empty metadata.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.