diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2025-10-02 17:36:27 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2025-10-02 17:36:27 +0200 |
| commit | dfca0f5bbebfe11d9c5d8bf6584bd1bf80d62274 (patch) | |
| tree | e033bb57affecf03fc03b678b3a876377441de9f /backend/data.go | |
| parent | a471baf6ee1b1a05acec23f2de1b74f56f4596a5 (diff) | |
feat(backend): og and twitter seo
Diffstat (limited to 'backend/data.go')
| -rw-r--r-- | backend/data.go | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/backend/data.go b/backend/data.go index adf5db3..e1a8478 100644 --- a/backend/data.go +++ b/backend/data.go @@ -1,11 +1,41 @@ package backend +import ( + "fmt" + "html/template" + "net/http" +) + type data struct { - title string - Article bool + title string + Article bool + Domain string + URL string + Image string + Description string +} + +func (d *data) handleGeneric(w http.ResponseWriter, name string) { + t, err := template.New("").Funcs(template.FuncMap{ + "static": func(path string) string { + return fmt.Sprintf("/static/%s", path) + }, + "assets": func(path string) string { + return fmt.Sprintf("/assets/%s", path) + }, + }).ParseFS(templates, fmt.Sprintf("templates/%s.html", name), "templates/base.html") + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + err = t.ExecuteTemplate(w, "base.html", d) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } } -func (d data) Title() string { +func (d *data) Title() string { title := "anhgelus" if d.Article { title += " - log entry" |
