owl-blogs/entry_types/recipe.go

41 lines
832 B
Go
Raw Normal View History

2023-07-16 19:48:39 +00:00
package entrytypes
2023-07-09 19:04:59 +00:00
import (
"fmt"
2023-07-16 19:48:39 +00:00
"owl-blogs/domain/model"
2023-07-09 19:04:59 +00:00
"owl-blogs/render"
)
type Recipe struct {
2023-07-16 19:48:39 +00:00
model.EntryBase
2023-07-09 19:04:59 +00:00
meta RecipeMetaData
}
type RecipeMetaData struct {
Title string `owl:"inputType=text"`
Yield string `owl:"inputType=text"`
Duration string `owl:"inputType=text"`
Ingredients []string `owl:"inputType=text widget=textarea"`
Content string `owl:"inputType=text widget=textarea"`
}
func (e *Recipe) Title() string {
return e.meta.Title
}
2023-07-16 19:48:39 +00:00
func (e *Recipe) Content() model.EntryContent {
2023-07-09 19:04:59 +00:00
str, err := render.RenderTemplateToString("entry/Recipe", e)
if err != nil {
fmt.Println(err)
}
2023-07-16 19:48:39 +00:00
return model.EntryContent(str)
2023-07-09 19:04:59 +00:00
}
func (e *Recipe) MetaData() interface{} {
return &e.meta
}
func (e *Recipe) SetMetaData(metaData interface{}) {
e.meta = *metaData.(*RecipeMetaData)
}