fix: typos and posts dates format

This commit is contained in:
Florian Sylvain
2024-06-11 11:57:28 +02:00
parent bcf3c19702
commit ad1692d168
3 changed files with 18 additions and 3 deletions
+13 -1
View File
@@ -7,11 +7,23 @@ import (
func GetPostsPage(w http.ResponseWriter, _ *http.Request) {
posts := Container.ListPostsUseCase.ListPosts()
var formattedPosts []map[string]interface{}
for _, post := range posts {
formattedPosts = append(formattedPosts, map[string]interface{}{
"ID": post.ID,
"Title": post.Title,
"CreatedAt": post.CreatedAt.Format("2006-01-02 15:04:05"),
"UpdatedAt": post.UpdatedAt.Format("2006-01-02 15:04:05"),
})
}
navbarTmpl, _ := Container.GetPageUseCase.GetPage("componentNavbar", nil)
postsTmpl, _ := Container.GetPageUseCase.GetPage("posts", map[string]interface{}{
"Navbar": template.HTML(navbarTmpl),
"Head": headTmpl,
"Posts": posts,
"Posts": formattedPosts,
})
_, _ = w.Write(postsTmpl)
}