added dynamic titles to pages for SEO

This commit is contained in:
rawleyIfowler
2022-02-27 12:24:52 -06:00
parent a2779c487c
commit 161f68ba85
6 changed files with 54 additions and 10 deletions

View File

@@ -64,17 +64,21 @@ func RegisterBlogGroup(r *gin.RouterGroup) {
func RenderBlogPage(c *gin.Context) {
posts := GetAllBlogPosts()
if posts == nil {
c.HTML(http.StatusInternalServerError, "internal_server_error.tmpl", gin.H{})
c.HTML(http.StatusInternalServerError, "internal_server_error.tmpl", models.Page{Title: " | 500"})
} else {
c.HTML(http.StatusOK, "blog.tmpl", posts)
c.HTML(http.StatusOK, "blog.tmpl", struct {
Posts []models.BlogPost
Title string
}{Posts: *posts, Title: " | blog"})
}
}
func RenderIndividualBlogPost(c *gin.Context) {
bp := GetBlogPostById(c.Param("url"))
if bp == nil {
c.HTML(http.StatusNotFound, "not_found.tmpl", gin.H{})
c.HTML(http.StatusNotFound, "not_found.tmpl", models.Page{Title: " | 404"})
} else {
// Blog posts handle the title themselves
c.HTML(http.StatusOK, "blog_post.tmpl", struct {
Post *models.BlogPost
Captcha [2]int