new: Add RSS Feed

This commit is contained in:
2024-12-19 12:13:56 +08:00
parent cbd6d07d52
commit 2a5d17676f
11 changed files with 95 additions and 40 deletions

View File

@@ -457,6 +457,9 @@ func (ma *MApp) UpdateBlogHandler(ctx *gin.Context) {
// parse post index
ma.loadPostIndex()
// parse rss
ma.RSS = ma.generateRSS()
log.Println("update blog success")
ctx.JSON(http.StatusOK, gin.H{"msg": "ok"})
}
@@ -485,3 +488,11 @@ func (ma *MApp) AboutHandler(ctx *gin.Context) {
ctx.HTML(http.StatusOK, "about.html", resData)
}
func (ma *MApp) RSSHandler(ctx *gin.Context) {
if ma.RSS != "" {
ctx.String(http.StatusOK, ma.RSS)
} else {
ctx.String(http.StatusNotFound, "RSS Not Found")
}
}