From f829b01a1c92e788f5114cf66c24856be23ec88f Mon Sep 17 00:00:00 2001 From: JP Appel Date: Mon, 28 Jul 2025 18:03:38 -0400 Subject: Add yaml output format --- pkg/index/index.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'pkg/index/index.go') diff --git a/pkg/index/index.go b/pkg/index/index.go index 8c21e72..f4e4593 100644 --- a/pkg/index/index.go +++ b/pkg/index/index.go @@ -70,6 +70,20 @@ func (idx Index) String() string { } var _ yaml.NodeUnmarshaler = (*Document)(nil) +var _ yaml.BytesMarshaler = (*Document)(nil) + +func (doc *Document) MarshalYAML() ([]byte, error) { + return yaml.Marshal(yaml.MapSlice{ + {Key: "path", Value: doc.Path}, + {Key: "title", Value: doc.Title}, + {Key: "date", Value: doc.Date}, + {Key: "filetime", Value: doc.FileTime}, + {Key: "authors", Value: doc.Authors}, + {Key: "tags", Value: doc.Tags}, + {Key: "links", Value: doc.Links}, + {Key: "meta", Value: doc.OtherMeta}, + }) +} func (doc *Document) UnmarshalYAML(node ast.Node) error { // parse top level fields -- cgit v1.2.3