Add content title and description helpers

pull/1/head
Nikita Tokarchuk 3 years ago
parent 7a694bcbe8
commit f3ed0ccc0a
Signed by: mainnika
GPG Key ID: A595FB7E3E56911C
  1. 12
      frontend/content/blog.go
  2. 10
      frontend/content/error.go
  3. 18
      frontend/content/index.go

@ -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:"
}

Loading…
Cancel
Save