Add tag description.

This commit is contained in:
2025-05-24 20:38:05 +08:00
parent 73815560b4
commit c55dc709e0
8 changed files with 231 additions and 20 deletions

View File

@@ -40,7 +40,7 @@ func handleRobotsTxt(c fiber.Ctx) error {
c.Set("Content-Type", "text/plain; charset=utf-8")
c.Set("Cache-Control", "no-cache")
c.Set("X-Robots-Tag", "noindex")
return c.SendString("User-agent: *\nDisallow: /api/\nDisallow: /admin/\n")
return c.SendString("User-agent: *\nDisallow: /api/\n\nSitemap: " + c.BaseURL() + "/sitemap.xml\n")
}
func handleSiteMap(c fiber.Ctx) error {
@@ -92,6 +92,13 @@ func serveIndexHtml(c fiber.Ctx) error {
title = u.Username
description = "User " + u.Username + "'s profile"
}
} else if strings.HasPrefix(path, "/tag/") {
tagName := strings.TrimPrefix(path, "/tag/")
t, err := service.GetTagByName(tagName)
if err == nil {
title = "Tag: " + t.Name
description = utils.ArticleToDescription(t.Description, 256)
}
}
content = strings.ReplaceAll(content, "{{SiteName}}", siteName)