shitty-ssg/cmd/notes/note/notes.go

34 lines
517 B
Go
Raw Normal View History

package note
import (
"io/ioutil"
2024-03-08 09:27:24 +01:00
"code.ewintr.nl/shitty-ssg/pkg/adoc"
)
type Notes []*Note
func (n *Notes) AddFileNote(fPath string) error {
content, err := ioutil.ReadFile(fPath)
if err != nil {
return err
}
note := NewNote(adoc.New(string(content)))
if note.Kind != KIND_INVALID {
*n = append(*n, note)
}
return nil
}
func (n *Notes) FilterByTerm(term string) Notes {
found := Notes{}
for _, note := range *n {
if note.Contains(term) {
found = append(found, note)
}
}
return found
}