frontmatter

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 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 string, name string) error

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

Types

type CustomTime

type CustomTime struct {
	time.Time
}

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"`
}

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