Fix image meta

This commit is contained in:
2025-05-18 16:17:03 +08:00
parent b536adce13
commit 562f5097d5

View File

@@ -46,9 +46,10 @@ func serveIndexHtml(c fiber.Ctx) error {
url := serverBaseURL + c.Path() url := serverBaseURL + c.Path()
cfTurnstileSiteKey := config.CloudflareTurnstileSiteKey() cfTurnstileSiteKey := config.CloudflareTurnstileSiteKey()
siteInfo := config.SiteInfo() siteInfo := config.SiteInfo()
path := c.Path()
if strings.HasPrefix(url, "/resources/") { if strings.HasPrefix(path, "/resources/") {
idStr := strings.TrimPrefix(url, "/resources/") idStr := strings.TrimPrefix(path, "/resources/")
id, err := strconv.Atoi(idStr) id, err := strconv.Atoi(idStr)
if err == nil { if err == nil {
r, err := service.GetResource(uint(id)) r, err := service.GetResource(uint(id))
@@ -60,8 +61,8 @@ func serveIndexHtml(c fiber.Ctx) error {
description = getResourceDescription(r.Article) description = getResourceDescription(r.Article)
} }
} }
} else if strings.HasPrefix(url, "/user/") { } else if strings.HasPrefix(path, "/user/") {
username := strings.TrimPrefix(url, "/user/") username := strings.TrimPrefix(path, "/user/")
u, err := service.GetUserByUsername(username) u, err := service.GetUserByUsername(username)
if err == nil { if err == nil {
preview = fmt.Sprintf("/avatar/%d", u.ID) preview = fmt.Sprintf("/avatar/%d", u.ID)