discard post types. Need a new approach for this

This commit is contained in:
Niko Abeler 2022-12-15 19:23:28 +01:00
parent ff50adac78
commit a49deabf07
3 changed files with 1 additions and 54 deletions

View File

@ -26,7 +26,7 @@ type GenericPost struct {
}
func (post *GenericPost) TemplateDir() string {
return "article"
return post.Meta().Type
}
type Post interface {

View File

@ -1,41 +0,0 @@
package owl
type Note struct {
GenericPost
}
func (n *Note) TemplateDir() string {
return "note"
}
type Article struct {
GenericPost
}
func (a *Article) TemplateDir() string {
return "article"
}
type Page struct {
GenericPost
}
func (p *Page) TemplateDir() string {
return "page"
}
type Bookmark struct {
GenericPost
}
func (b *Bookmark) TemplateDir() string {
return "bookmark"
}
type Reply struct {
GenericPost
}
func (r *Reply) TemplateDir() string {
return "reply"
}

12
user.go
View File

@ -285,18 +285,6 @@ func (user User) GetPost(id string) (Post, error) {
}
post := GenericPost{user: &user, id: id}
switch post.Meta().Type {
case "article":
return &Article{GenericPost: post}, nil
case "note":
return &Note{GenericPost: post}, nil
case "reply":
return &Reply{GenericPost: post}, nil
case "bookmark":
return &Bookmark{GenericPost: post}, nil
case "page":
return &Page{GenericPost: post}, nil
}
return &post, nil
}