mirror of
https://github.com/mainnika/nikita-tokarch-uk.git
synced 2026-05-25 01:03:35 +00:00
Add content title and description helpers
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package content
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/ghost"
|
||||
)
|
||||
|
||||
@@ -11,3 +13,13 @@ type Blog struct {
|
||||
Pinned []ghost.Post
|
||||
Posts []ghost.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:"
|
||||
}
|
||||
|
||||
@@ -6,3 +6,13 @@ type Error struct {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -11,3 +11,21 @@ type Index struct {
|
||||
Pinned []ghost.Post
|
||||
Posts []ghost.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:"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user