Diffstat (limited to 'internal/router/api-v1-blog-search.go')
| -rw-r--r-- | internal/router/api-v1-blog-search.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/internal/router/api-v1-blog-search.go b/internal/router/api-v1-blog-search.go index 2997407..e22fabe 100644 --- a/internal/router/api-v1-blog-search.go +++ b/internal/router/api-v1-blog-search.go @@ -10,12 +10,15 @@ import ( "time" "github.com/SayaAndy/saya-today-web/internal/b2" - "github.com/SayaAndy/saya-today-web/internal/templatemanager" "github.com/SayaAndy/saya-today-web/locale" "github.com/gofiber/fiber/v2" ) -func Api_V1_BlogSearch(tm *templatemanager.TemplateManager, l map[string]*locale.LocaleConfig, langs []string, b2Client *b2.B2Client) func(c *fiber.Ctx) error { +func init() { + tm.Add("catalogue-blog-cards", "views/partials/catalogue-blog-cards.html", "views/partials/catalogue-blog-card-tags.html") +} + +func Api_V1_BlogSearch(l map[string]*locale.LocaleConfig, langs []string, b2Client *b2.B2Client) func(c *fiber.Ctx) error { return func(c *fiber.Ctx) error { sort := c.Query("sort") lang := c.Query("lang") @@ -45,7 +48,7 @@ func Api_V1_BlogSearch(tm *templatemanager.TemplateManager, l map[string]*locale c.Set(fiber.HeaderContentType, fiber.MIMETextPlainCharsetUTF8) return c.Status(fiber.ErrInternalServerError.Code).SendString("failed to generate regex for tags gathering") } - decodedQuery, err := url.QueryUnescape(string(encodedQuery)) + decodedQuery, _ := url.QueryUnescape(string(encodedQuery)) matches := re.FindAllStringSubmatch(decodedQuery, -1) tags := make([]string, 0, len(matches)) @@ -66,6 +69,7 @@ func Api_V1_BlogSearch(tm *templatemanager.TemplateManager, l map[string]*locale "ShortDescription": page.Metadata.ShortDescription, "Thumbnail": page.Metadata.Thumbnail, "Tags": page.Metadata.Tags, + "LikeCount": CCache.GetLikeCount(page.FileName), }) break } |