summaryrefslogtreecommitdiffci
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
-rw-r--r--internal/router/basic-handler.go6
-rw-r--r--internal/router/handlers/lang-blog-title.go14
-rw-r--r--internal/router/handlers/lang-blog.go9
-rw-r--r--internal/router/handlers/lang-user.go11
-rw-r--r--internal/router/handlers/lang.go12
-rw-r--r--internal/router/handlers/root.go11
-rw-r--r--internal/router/router.go8
-rw-r--r--locale/localization.en.yaml1
-rw-r--r--locale/localization.go1
-rw-r--r--locale/localization.ru.yaml1
-rw-r--r--views/layouts/general-page.html10
-rw-r--r--views/pages/global-map.html8
12 files changed, 28 insertions, 64 deletions
diff --git a/internal/router/basic-handler.go b/internal/router/basic-handler.go
index 96d0f77..98a7d84 100644
--- a/internal/router/basic-handler.go
+++ b/internal/router/basic-handler.go
@@ -49,8 +49,10 @@ func (r *BasicHandler) Render(c *fiber.Ctx, supplements *Supplements, lang strin
return fiber.StatusNoContent, nil
}
-func (r *BasicHandler) AddMeta(c *fiber.Ctx, supplements *Supplements, lang string, templateMap fiber.Map) (meta []MetaField, err error) {
- return []MetaField{{Name: "robots", Content: "noindex,nofollow"}}, nil
+func (r *BasicHandler) AddMeta(c *fiber.Ctx, supplements *Supplements, lang string, templateMap fiber.Map) (meta map[string]string, err error) {
+ return map[string]string{
+ "robots": "noindex,nofollow",
+ }, nil
}
func (r *BasicHandler) RenderHeader(c *fiber.Ctx, supplements *Supplements, lang string, templateMap fiber.Map) (statusCode int, err error) {
diff --git a/internal/router/handlers/lang-blog-title.go b/internal/router/handlers/lang-blog-title.go
index a9acdbb..9eac084 100644
--- a/internal/router/handlers/lang-blog-title.go
+++ b/internal/router/handlers/lang-blog-title.go
@@ -65,19 +65,17 @@ func (r *BlogPageHandler) SitemapInfo(supplements *router.Supplements) []router.
return sitemapInfo
}
-func (r *BlogPageHandler) AddMeta(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (meta []router.MetaField, err error) {
+func (r *BlogPageHandler) AddMeta(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (meta map[string]string, err error) {
metadata, _, err := supplements.B2Client.ReadFrontmatter(lang + "/" + c.Params("title") + ".md")
if err != nil {
return nil, fmt.Errorf("failed to read frontmatter of the desired blog post: %w", err)
}
- return []router.MetaField{
- {Property: "og:title", Content: metadata.Title},
- {Property: "og:description", Content: fmt.Sprintf("%s [%s]", metadata.ShortDescription, metadata.ActionDate)},
- {Property: "og:image", Content: fmt.Sprintf("https://f003.backblazeb2.com/file/sayana-photos/webp-320p/%s.webp", metadata.Thumbnail)},
- {Property: "og:url", Content: fmt.Sprintf("%s/%s/blog/%s", templateMap["CanonicalEndpoint"], lang, c.Params("title"))},
- {Property: "og:type", Content: "website"},
- {Name: "twitter:card", Content: "summary_large_image"},
+ return map[string]string{
+ "og:title": metadata.Title,
+ "og:description": fmt.Sprintf("%s [%s]", metadata.ShortDescription, metadata.ActionDate),
+ "og:image": fmt.Sprintf("https://f003.backblazeb2.com/file/sayana-photos/webp-320p/%s.webp", metadata.Thumbnail),
+ "twitter:card": "summary_large_image",
}, nil
}
diff --git a/internal/router/handlers/lang-blog.go b/internal/router/handlers/lang-blog.go
index 709d3dc..ffac77e 100644
--- a/internal/router/handlers/lang-blog.go
+++ b/internal/router/handlers/lang-blog.go
@@ -55,15 +55,6 @@ func (r *CatalogueHandler) SitemapInfo(supplements *router.Supplements) []router
return sitemapInfo
}
-func (r *CatalogueHandler) AddMeta(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (meta []router.MetaField, err error) {
- return []router.MetaField{
- {Property: "og:title", Content: supplements.Localization[lang].BlogSearch.Header},
- {Property: "og:description", Content: supplements.Localization[lang].BlogSearch.Description},
- {Property: "og:url", Content: fmt.Sprintf("%s/%s/blog", templateMap["CanonicalEndpoint"], lang)},
- {Property: "og:type", Content: "website"},
- }, nil
-}
-
func (r *CatalogueHandler) RenderBody(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (statusCode int, err error) {
querySort := c.Query("sort")
if querySort == "" {
diff --git a/internal/router/handlers/lang-user.go b/internal/router/handlers/lang-user.go
index eae1685..c22bcac 100644
--- a/internal/router/handlers/lang-user.go
+++ b/internal/router/handlers/lang-user.go
@@ -37,13 +37,10 @@ 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: supplements.Localization[lang].UserProfile.Header},
- {Property: "og:description", Content: supplements.Localization[lang].UserProfile.Description},
- {Property: "og:url", Content: fmt.Sprintf("%s/%s/user", templateMap["CanonicalEndpoint"], lang)},
- {Property: "og:type", Content: "website"},
+func (r *UserHandler) AddMeta(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (meta map[string]string, err error) {
+ return map[string]string{
+ "og:title": supplements.Localization[lang].BlogSearch.Header,
+ "og:description": supplements.Localization[lang].BlogSearch.Description,
}, nil
}
diff --git a/internal/router/handlers/lang.go b/internal/router/handlers/lang.go
index c618353..5430773 100644
--- a/internal/router/handlers/lang.go
+++ b/internal/router/handlers/lang.go
@@ -49,13 +49,11 @@ func (r *HomeHandler) SitemapInfo(supplements *router.Supplements) []router.Site
return sitemapInfo
}
-func (r *HomeHandler) AddMeta(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (meta []router.MetaField, err error) {
- return []router.MetaField{
- {Property: "og:title", Content: supplements.Localization[lang].HomePage.Header},
- {Property: "og:description", Content: supplements.Localization[lang].HomePage.HomePageDescription},
- {Property: "og:image", Content: fmt.Sprintf("https://f003.backblazeb2.com/file/sayana-static/home-page-gifs/otter-%d.gif", rand.Int()%3+1)},
- {Property: "og:url", Content: fmt.Sprintf("%s/%s", templateMap["CanonicalEndpoint"], lang)},
- {Property: "og:type", Content: "website"},
+func (r *HomeHandler) AddMeta(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (meta map[string]string, err error) {
+ return map[string]string{
+ "og:title": supplements.Localization[lang].HomePage.Header,
+ "og:description": supplements.Localization[lang].HomePage.HomePageDescription,
+ "og:image": "https://f003.backblazeb2.com/file/sayana-static/home-page-gifs/" + fmt.Sprintf("otter-%d.gif", rand.Int()%3+1),
}, nil
}
diff --git a/internal/router/handlers/root.go b/internal/router/handlers/root.go
index f188a61..89b9c63 100644
--- a/internal/router/handlers/root.go
+++ b/internal/router/handlers/root.go
@@ -1,7 +1,6 @@
package handlers
import (
- "fmt"
"time"
"github.com/SayaAndy/saya-today-web/internal/router"
@@ -40,12 +39,10 @@ func (r *RootHandler) SitemapInfo(_ *router.Supplements) []router.SitemapInfo {
return []router.SitemapInfo{{Loc: "", Priority: 0.7}}
}
-func (r *RootHandler) AddMeta(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (meta []router.MetaField, err error) {
- return []router.MetaField{
- {Property: "og:title", Content: "Saya Blog"},
- {Property: "og:description", Content: "The blog of a 25 years old, travelling God knows where, proud to be not mainstream // Личный блог 25-летки, странствующего по ебеням, зато не мейнстрим"},
- {Property: "og:url", Content: fmt.Sprint(templateMap["CanonicalEndpoint"])},
- {Property: "og:type", Content: "website"},
+func (r *RootHandler) AddMeta(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (meta map[string]string, err error) {
+ return map[string]string{
+ "og:title": "Saya Blog",
+ "og:description": "The blog of a 25 years old, travelling God knows where, proud to be not mainstream // Личный блог 25-летки, странствующего по ебеням, зато не мейнстрим",
}, nil
}
diff --git a/internal/router/router.go b/internal/router/router.go
index 1b490d8..56313ff 100644
--- a/internal/router/router.go
+++ b/internal/router/router.go
@@ -59,12 +59,6 @@ type SitemapInfo struct {
Priority float32
}
-type MetaField struct {
- Name string
- Property string
- Content string
-}
-
type Route interface {
Filter() (method string, path string)
IsTemplated() bool
@@ -75,7 +69,7 @@ type Route interface {
SitemapInfo(supplements *Supplements) []SitemapInfo
ContentType() string
Render(c *fiber.Ctx, supplements *Supplements, lang string, templateMap fiber.Map) (statusCode int, err error)
- AddMeta(c *fiber.Ctx, supplements *Supplements, lang string, templateMap fiber.Map) (meta []MetaField, err error)
+ AddMeta(c *fiber.Ctx, supplements *Supplements, lang string, templateMap fiber.Map) (meta map[string]string, err error)
RenderHeader(c *fiber.Ctx, supplements *Supplements, lang string, templateMap fiber.Map) (statusCode int, err error)
RenderBody(c *fiber.Ctx, supplements *Supplements, lang string, templateMap fiber.Map) (statusCode int, err error)
RenderFooter(c *fiber.Ctx, supplements *Supplements, lang string, templateMap fiber.Map) (statusCode int, err error)
diff --git a/locale/localization.en.yaml b/locale/localization.en.yaml
index 9923881..e165866 100644
--- a/locale/localization.en.yaml
+++ b/locale/localization.en.yaml
@@ -48,7 +48,6 @@ Mail:
CapturedOn: 'Captured on'
UserProfile:
Header: 'Personal Settings'
- Description: 'Set and verify your e-mail here, as well as subscribe to favorite blog tags'
EmailHeader: 'E-Mail'
VerificationCodeHeader: 'Verification Code'
TypeEmail: 'Please type your email'
diff --git a/locale/localization.go b/locale/localization.go
index 7080355..a4f36f1 100644
--- a/locale/localization.go
+++ b/locale/localization.go
@@ -85,7 +85,6 @@ type NewPostConfig struct {
type UserProfileConfig struct {
Header string `yaml:"Header" json:"Header"`
- Description string `yaml:"Description" json:"Description"`
EmailHeader string `yaml:"EmailHeader" json:"EmailHeader"`
VerificationCodeHeader string `yaml:"VerificationCodeHeader" json:"VerificationCodeHeader"`
TypeEmail string `yaml:"TypeEmail" json:"TypeEmail"`
diff --git a/locale/localization.ru.yaml b/locale/localization.ru.yaml
index 34e5387..e65848a 100644
--- a/locale/localization.ru.yaml
+++ b/locale/localization.ru.yaml
@@ -48,7 +48,6 @@ Mail:
CapturedOn: 'Снималось'
UserProfile:
Header: 'Личные настройки'
- Description: 'Здесь можно настроить и верифицировать свою электронную почту, а также подписаться на избранные темы блога'
EmailHeader: 'E-Mail'
VerificationCodeHeader: 'Код верификации'
TypeEmail: 'Пожалуйста, введите свою почту'
diff --git a/views/layouts/general-page.html b/views/layouts/general-page.html
index 2114b1c..3f5bcfd 100644
--- a/views/layouts/general-page.html
+++ b/views/layouts/general-page.html
@@ -3,14 +3,8 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
- {{- range .Meta }}
- <meta {{with .Name}}name="{{.}}" {{end}}{{with .Property}}property="{{.}}" {{end}}{{with .Content}}content="{{.}}"{{end}}>
- {{- if eq .Property "og:description" }}
- <meta name="description" href="{{.Content}}">
- {{- end }}
- {{- if eq .Property "og:url" }}
- <link rel="canonical" href="{{.Content}}">
- {{- end }}
+ {{- range $k, $v := .Meta }}
+ <meta name="{{ $k }}" content="{{ $v }}">
{{- end }}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css">
<link rel="stylesheet" href="https://f003.backblazeb2.com/file/sayana-static/libs/leaflet/1.9.4/leaflet.css">
diff --git a/views/pages/global-map.html b/views/pages/global-map.html
index 604b52e..4b07bd2 100644
--- a/views/pages/global-map.html
+++ b/views/pages/global-map.html
@@ -3,13 +3,9 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="description" content="{{ .L.GlobalMap.Description }}">
- <meta property="og:title" content="{{ .L.GlobalMap.Header }}">
- <meta property="og:description" content="{{ .L.GlobalMap.Description }}">
- <meta property="og:url" content="{{ .CanonicalEndpoint }}/{{ .Lang }}/map">
- <meta property="og:type" content="site">
+ <meta name="og:title" content="{{ .L.GlobalMap.Header }}">
+ <meta name="og:description" content="{{ .L.GlobalMap.Description }}">
<title>{{ .L.GlobalMap.Header }} // SAYA TODAY</title>
- <link rel="canonical" href="{{ .CanonicalEndpoint }}/{{ .Lang }}/map">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css">
{{ block "header" . }}{{ end }}
<link href="/output.css" rel="stylesheet">