frontmatter

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package frontmatter provides functionality to generate YAML frontmatter headers for Markdown files.

Index

Constants

View Source
const HumanTimeLayout = "2006-01-02 15:04"

Variables

This section is empty.

Functions

func Create

func Create(path, name string) error

Create generates a YAML frontmatter block with title, creation/update timestamps, and writes it to the specified file path.

func Update added in v1.4.3

func Update(path, name string) error

Update takes the frontmatter that was added with template and replaces name and dates.

Types

type CustomTime

type CustomTime struct {
	time.Time
}

func (CustomTime) MarshalYAML added in v1.4.3

func (ct CustomTime) MarshalYAML() (any, error)

func (*CustomTime) UnmarshalYAML

func (ct *CustomTime) UnmarshalYAML(value *yaml.Node) error

type Document

type Document struct {
	Meta    Frontmatter
	Content []byte
	Path    string
}

Document represents a fully parsed Markdown file, including its metadata, body content, and file path.

func ParseFile

func ParseFile(filePath string) (Document, error)

ParseFile reads a markdown note, extracts the YAML metadata, parses it into a Frontmatter struct, and returns the full Document.

type Frontmatter

type Frontmatter struct {
	Title   string     `yaml:"title"`
	Created CustomTime `yaml:"created"`
	Updated CustomTime `yaml:"updated"`
	Tags    []string   `yaml:"tags,flow"`
}

Frontmatter represents the metadata parsed from the YAML header of a note.

Jump to

Keyboard shortcuts

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