mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 04:17:23 +00:00
Improve comments
This commit is contained in:
@@ -90,7 +90,7 @@ func serveIndexHtml(c fiber.Ctx) error {
|
||||
username := strings.TrimPrefix(path, "/user/")
|
||||
u, err := service.GetUserByUsername(username)
|
||||
if err == nil {
|
||||
preview = fmt.Sprintf("/avatar/%d", u.ID)
|
||||
preview = fmt.Sprintf("%s/avatar/%d", serverBaseURL, u.ID)
|
||||
title = u.Username
|
||||
description = "User " + u.Username + "'s profile"
|
||||
}
|
||||
@@ -105,6 +105,17 @@ func serveIndexHtml(c fiber.Ctx) error {
|
||||
description = utils.ArticleToDescription(t.Description, 256)
|
||||
}
|
||||
}
|
||||
} else if strings.HasPrefix(path, "/comments/") {
|
||||
commentIDStr := strings.TrimPrefix(path, "/comments/")
|
||||
commentID, err := strconv.Atoi(commentIDStr)
|
||||
if err == nil {
|
||||
cmt, err := service.GetCommentByID(uint(commentID))
|
||||
if err == nil {
|
||||
title = "Comment Details"
|
||||
description = utils.ArticleToDescription(cmt.Content, 200)
|
||||
preview = fmt.Sprintf("%s/avatar/%d", serverBaseURL, cmt.User.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
content = strings.ReplaceAll(content, "{{SiteName}}", siteName)
|
||||
|
Reference in New Issue
Block a user