diff options
| author | JP Appel <jeanpierre.appel01@gmail.com> | 2025-07-28 18:03:38 -0400 |
|---|---|---|
| committer | JP Appel <jeanpierre.appel01@gmail.com> | 2025-07-28 18:24:10 -0400 |
| commit | f829b01a1c92e788f5114cf66c24856be23ec88f (patch) | |
| tree | 3342db120daad20da5d0124c2b02bc5cd47cc086 /pkg/index | |
| parent | 83e2cd972d12979232eb8c1043ad3d649d03880d (diff) | |
Add yaml output format
Diffstat (limited to 'pkg/index')
| -rw-r--r-- | pkg/index/index.go | 14 |
1 files changed, 14 insertions, 0 deletions
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 |
