summaryrefslogtreecommitdiffci
path: root/internal/router/handlers/lang-user.go
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
Diffstat (limited to 'internal/router/handlers/lang-user.go')
-rw-r--r--internal/router/handlers/lang-user.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/internal/router/handlers/lang-user.go b/internal/router/handlers/lang-user.go
index db566fe..085a9aa 100644
--- a/internal/router/handlers/lang-user.go
+++ b/internal/router/handlers/lang-user.go
@@ -6,6 +6,7 @@ import (
"github.com/SayaAndy/saya-today-web/internal/mailer"
"github.com/SayaAndy/saya-today-web/internal/router"
+ "github.com/SayaAndy/saya-today-web/l10n"
"github.com/gofiber/fiber/v2"
)
@@ -37,15 +38,25 @@ func (r *UserHandler) ToValidateLang() router.LangSetting {
return router.InPath
}
+func (r *UserHandler) AddMeta(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (meta []router.MetaField, err error) {
+ return []router.MetaField{
+ {Name: "robots", Content: "noindex,nofollow"},
+ {Property: "og:title", Content: l10n.T.GetPath(lang, "UserProfile", "Header").(string)},
+ {Property: "og:description", Content: l10n.T.GetPath(lang, "UserProfile", "Description").(string)},
+ {Property: "og:url", Content: fmt.Sprintf("%s/%s/user", templateMap["CanonicalEndpoint"], lang)},
+ {Property: "og:type", Content: "website"},
+ }, nil
+}
+
func (r *UserHandler) RenderBody(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (statusCode int, err error) {
- templateMap["Title"] = supplements.Localization[lang].UserProfile.Header
+ templateMap["Title"] = l10n.T.GetPath(lang, "UserProfile", "Header").(string)
email, _, err := supplements.Mailer.GetInfo(supplements.Mailer.GetHash(c.IP()))
if err != nil {
slog.Error("get info from mailer about a client", slog.String("error", err.Error()))
}
- tagsArray, err := getTags(supplements.B2Client, lang)
+ tagsArray, err := getTags(supplements.BlogClient, lang)
if err != nil {
return fiber.ErrInternalServerError.Code, fmt.Errorf("failed to get the available tags")
}
@@ -73,6 +84,6 @@ func (r *UserHandler) RenderBody(c *fiber.Ctx, supplements *router.Supplements,
}
func (r *UserHandler) RenderHeader(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (statusCode int, err error) {
- templateMap["Title"] = supplements.Localization[lang].UserProfile.Header
+ templateMap["Title"] = l10n.T.GetPath(lang, "UserProfile", "Header").(string)
return fiber.StatusOK, nil
}