mirror of
https://github.com/mainnika/nikita-tokarch-uk.git
synced 2026-05-25 01:03:35 +00:00
Load blog page data as the content
This commit is contained in:
@@ -1,6 +1,13 @@
|
|||||||
package content
|
package content
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/ghost"
|
||||||
|
)
|
||||||
|
|
||||||
// Blog content data
|
// Blog content data
|
||||||
type Blog struct {
|
type Blog struct {
|
||||||
_ interface{} `template:"blog.go.tmpl"`
|
_ interface{} `template:"blog.go.tmpl"`
|
||||||
|
ghost.Meta
|
||||||
|
Pinned []ghost.Post
|
||||||
|
Posts []ghost.Post
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,24 @@ package renderer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/content"
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/content"
|
||||||
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/ghost"
|
||||||
routing "github.com/jackwhelpton/fasthttp-routing/v2"
|
routing "github.com/jackwhelpton/fasthttp-routing/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// blog handler renders blog data
|
// blog handler renders blog data
|
||||||
func (r *Renderer) blog(c *routing.Context) (err error) {
|
func (r *Renderer) blog(c *routing.Context) (err error) {
|
||||||
|
|
||||||
|
postsPerPage := r.ContentConfig.PostsPerPage
|
||||||
|
currentPage := c.QueryArgs().GetUintOrZero("page")
|
||||||
|
|
||||||
|
latestPosts, err := r.GhostClient.GetPosts(ghost.QueryLimit(postsPerPage), ghost.QueryPage(currentPage))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
blogContent := content.Blog{
|
blogContent := content.Blog{
|
||||||
|
Meta: latestPosts.Meta,
|
||||||
|
Posts: latestPosts.Posts,
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.Write(blogContent)
|
return c.Write(blogContent)
|
||||||
|
|||||||
Reference in New Issue
Block a user