added catch for empty blog posts

This commit is contained in:
rawleyIfowler
2022-02-26 10:20:08 -06:00
parent b1c76c2094
commit a13e1f5c87

View File

@@ -61,10 +61,9 @@ func RegisterBlogGroup(r *gin.RouterGroup) {
func RenderBlogPage(c *gin.Context) { func RenderBlogPage(c *gin.Context) {
posts := GetAllBlogPosts() posts := GetAllBlogPosts()
if posts == nil { if posts == nil {
c.HTML(http.StatusInternalServerError, "internal_server_error.tmpl", gin.H{}) posts = &[]models.BlogPost{}
} else {
c.HTML(http.StatusOK, "blog.tmpl", posts)
} }
c.HTML(http.StatusOK, "blog.tmpl", posts)
} }
func RenderIndividualBlogPost(c *gin.Context) { func RenderIndividualBlogPost(c *gin.Context) {