owl-blogs/domain/model/article.go

37 lines
629 B
Go
Raw Normal View History

2023-07-08 13:59:26 +00:00
package model
2023-07-09 17:51:49 +00:00
import (
"fmt"
"owl-blogs/render"
)
2023-07-08 13:59:26 +00:00
type Article struct {
EntryBase
meta ArticleMetaData
}
type ArticleMetaData struct {
Title string `owl:"inputType=text"`
Content string `owl:"inputType=text widget=textarea"`
}
2023-07-09 17:51:49 +00:00
func (e *Article) Title() string {
return e.meta.Title
}
2023-07-08 13:59:26 +00:00
func (e *Article) Content() EntryContent {
2023-07-09 17:51:49 +00:00
str, err := render.RenderTemplateToString("entry/Article", e)
if err != nil {
fmt.Println(err)
}
return EntryContent(str)
2023-07-08 13:59:26 +00:00
}
func (e *Article) MetaData() interface{} {
return &e.meta
}
func (e *Article) SetMetaData(metaData interface{}) {
e.meta = *metaData.(*ArticleMetaData)
}