Load blog page data as the content

This commit is contained in:
2021-12-03 04:05:29 +01:00
parent 47029b5a4c
commit 7a694bcbe8
2 changed files with 18 additions and 0 deletions
+11
View File
@@ -2,13 +2,24 @@ package renderer
import (
"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"
)
// blog handler renders blog data
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{
Meta: latestPosts.Meta,
Posts: latestPosts.Posts,
}
return c.Write(blogContent)