frontmatter

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Delimiter               = "---" // YAML frontmatter 的起止分隔符
	NoFrontmatterError      = "note does not contain frontmatter"
	InvalidFrontmatterError = "frontmatter contains invalid YAML"
)

Variables

This section is empty.

Functions

func DeleteKey

func DeleteKey(content, key string) (string, error)

DeleteKey 从 frontmatter 中删除指定 key,返回更新后的完整内容。

func Format

func Format(fm map[string]interface{}) (string, error)

Format 将 frontmatter map 转换为 YAML 字符串。

func HasFrontmatter

func HasFrontmatter(content string) bool

HasFrontmatter 检查内容是否以 frontmatter 分隔符开头。

func Parse

func Parse(content string) (map[string]interface{}, string, error)

Parse 从笔记内容中提取并解析 YAML frontmatter。 返回 frontmatter 的 map 表示、正文内容、以及可能的错误。

func SetKey

func SetKey(content, key, value string) (string, error)

SetKey 更新或添加 frontmatter 中的指定 key,返回更新后的完整内容。 如果笔记原本没有 frontmatter,会自动创建一个新的 frontmatter 块。

Types

This section is empty.

Jump to

Keyboard shortcuts

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