note

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package note implements nt's markdown notes with light YAML frontmatter (SPEC §5). Notes are one file each under notes/, so they need no shared lock: creation and edits are atomic single-file writes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Slug

func Slug(title string) string

Slug derives a filesystem-safe slug from a title, falling back to a timestamp when the title yields nothing usable (à la nb).

Types

type Note

type Note struct {
	Path    string
	Rel     string // path relative to notes/ (slash-separated), set by List
	ID      string
	Title   string
	Tags    []string
	Aliases []string
	Source  string
	Created string
	Updated string // stamped when nt rewrites the note (retag, --field)
	Body    string
	Extra   []string // raw frontmatter lines for keys nt doesn't model (preserved verbatim)
}

Note is a parsed markdown note.

func Create

func Create(s *store.Store, title, body string, tags []string, source, folder string) (*Note, error)

Create builds and writes a new note, returning it. The body is prefixed with an H1 title when it doesn't already start with one. Create writes a new note. folder, when non-empty, is a slash-separated subfolder under notes/ (e.g. "work" or "work/auth"); it is created as needed. The filename is slugged from the title; the body and frontmatter are written by Save.

func List

func List(s *store.Store) ([]*Note, error)

List loads all notes in the store's notes directory, recursing into subfolders so an Obsidian-style nested vault works. Hidden dirs (.obsidian/, .trash/, .git/) and non-.md files are skipped. Each note's Rel (path relative to notes/, slash-separated) is set for link resolution; results are sorted by Rel for deterministic ordering.

func Load

func Load(path string) (*Note, error)

Load parses a note file (frontmatter + body). Unknown frontmatter keys are ignored, not an error.

func (*Note) Save

func (n *Note) Save() error

Save writes the note atomically with frontmatter.

Jump to

Keyboard shortcuts

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