Add HTML template and implement homepage with random cat posts

This commit is contained in:
2025-05-14 20:39:56 +03:30
parent ac86f8d2f0
commit 3007b41f0d
3 changed files with 247 additions and 17 deletions
+6 -2
View File
@@ -17,7 +17,11 @@ func NewMainPageHandler(appContext *internal.AppContext) *MainPageHandler {
}
func (appContext *MainPageHandler) HomePageHandler(c *gin.Context) {
c.JSON(200, gin.H{
"YouAreOn": "HomePage",
randomPost := appContext.AppContext.PostService.GetRandomPost()
c.HTML(200, "index.tmpl", gin.H{
"DisplayName": randomPost.Account.DisplayName,
"MediaAttachment": randomPost.Attachments[0],
"URL": randomPost.Url,
})
}