diff options
| author | William Hergès <william@herges.fr> | 2025-10-03 20:47:55 +0200 |
|---|---|---|
| committer | William Hergès <william@herges.fr> | 2025-10-03 20:47:55 +0200 |
| commit | 97045512306ed91b690a0d4c20bbb8fe84d7dbfe (patch) | |
| tree | d3e6689c65999cfb91aef886424832b6ba3d52fe /backend/data.go | |
| parent | 12efe4691b85bf7b1933ac993b01ac7f0a06b06c (diff) | |
feat(backend): set default image and public folder in config
Diffstat (limited to 'backend/data.go')
| -rw-r--r-- | backend/data.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/backend/data.go b/backend/data.go index 741a5c4..3635a7e 100644 --- a/backend/data.go +++ b/backend/data.go @@ -58,6 +58,9 @@ func (d *data) handleGeneric(w http.ResponseWriter, r *http.Request, name string d.Quote = cfg.Quotes[rand.Intn(len(cfg.Quotes))] } } + if d.Image == "" { + d.Image = cfg.DefaultImage + } if d.URL == "" { if !strings.HasPrefix(r.URL.Path, "/") { r.URL.Path = "/" + r.URL.Path @@ -71,6 +74,12 @@ func (d *data) handleGeneric(w http.ResponseWriter, r *http.Request, name string } return fmt.Sprintf("/static/%s", path) }, + "fullStatic": func(path string) string { + if regexIsHttp.MatchString(path) { + return path + } + return fmt.Sprintf("https://%s/static/%s", cfg.Domain, path) + }, "assets": func(path string) string { if regexIsHttp.MatchString(path) { return path |
