Restructure the go package

This commit is contained in:
2021-12-16 21:57:05 +01:00
parent a9b5ac4df2
commit 39ef200967
26 changed files with 111 additions and 98 deletions
+25
View File
@@ -0,0 +1,25 @@
package content
import (
"fmt"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/data"
)
// Blog content data
type Blog struct {
_ interface{} `template:"blog.go.tmpl"`
data.Meta
Pinned []data.Post
Posts []data.Post
}
// Title returns blog content title
func (i Blog) Title() string {
return fmt.Sprintf("... %d of %d", i.Meta.Pagination.Page, i.Meta.Pagination.Pages)
}
// Description returns blog content description
func (i Blog) Description() string {
return "TODO:"
}
+18
View File
@@ -0,0 +1,18 @@
package content
// Error content data
type Error struct {
_ interface{} `template:"error.go.tmpl"`
Message string
}
// Title returns error title
func (e Error) Title() string {
return e.Message
}
// Description returns error description
func (e Error) Description() string {
return e.Message
}
+29
View File
@@ -0,0 +1,29 @@
package content
import "code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/data"
// Index content data
type Index struct {
_ interface{} `template:"index.go.tmpl"`
data.Meta
Pinned []data.Post
Posts []data.Post
}
// Title returns index title
func (i Index) Title() string {
if len(i.Pinned) > 0 {
return i.Pinned[0].Title
}
if len(i.Posts) > 0 {
return i.Posts[0].Title
}
return "UNKNOWN:"
}
// Description returns index description
func (i Index) Description() string {
return "TODO:"
}