all repos — searchix @ c3fa5a442ee81a4c2252736c4d4ef461c6b3af93

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: Add basic page meta description https://codeberg.org/alinnow/searchix/pulls/15

Kaya
commit

c3fa5a442ee81a4c2252736c4d4ef461c6b3af93

parent

078020ea68fd850a3d1dcfcdfbcb2ba61312161b

1 file changed, 25 insertions(+), 0 deletions(-)

changed files
M internal/components/page.gointernal/components/page.go
@@ -2,6 +2,7 @@ package components
import ( "net/url" + "strings" "alin.ovh/searchix/frontend" "alin.ovh/searchix/internal/config"
@@ -18,6 +19,23 @@ Lang("en-GB"),
Head( Meta(Charset("utf-8")), Meta(Name("viewport"), Content("width=device-width, initial-scale=1")), + g.If(tdata.Description != "", + g.Group([]g.Node{ + Meta(Name("description"), Content(tdata.Description)), + Meta(g.Attr("property", "og:description"), Content(tdata.Description)), + }), + ), + Meta(g.Attr("property", "og:type"), Content("website")), + Meta(g.Attr("property", "og:site_name"), Content("Searchix")), + Meta(g.Attr("property", "og:title"), Content(ogTitle(tdata.Title))), + g.If(tdata.BaseURL.URL != nil, + g.Group([]g.Node{ + Meta( + g.Attr("property", "og:image"), + Content(tdata.BaseURL.JoinPath("apple-touch-icon.png").String()), + ), + }), + ), TitleEl( g.Raw(tdata.Title), g.Text("Searchix"), g.If(config.DevMode, g.Text(" (Dev)")),
@@ -126,6 +144,13 @@ ),
), ), ) +} + +func ogTitle(title string) string { + t := strings.ReplaceAll(title, " ‐ ", " - ") + t += "Searchix" + + return t } func css(css *frontend.Asset) g.Node {