From 40b1f53362105a495c6a486f3488e83d79eb582a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Herg=C3=A8s?= Date: Fri, 3 Oct 2025 22:22:40 +0200 Subject: feat(markdown): eval option to setup custom image source func --- backend/data.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'backend/data.go') diff --git a/backend/data.go b/backend/data.go index 3635a7e..241f47a 100644 --- a/backend/data.go +++ b/backend/data.go @@ -68,12 +68,7 @@ func (d *data) handleGeneric(w http.ResponseWriter, r *http.Request, name string d.URL = r.URL.Path } t, err := template.New("").Funcs(template.FuncMap{ - "static": func(path string) string { - if regexIsHttp.MatchString(path) { - return path - } - return fmt.Sprintf("/static/%s", path) - }, + "static": getStatic, "fullStatic": func(path string) string { if regexIsHttp.MatchString(path) { return path @@ -123,3 +118,10 @@ func (d *data) Title() string { func (d *data) PubDate() string { return "" } + +func getStatic(path string) string { + if regexIsHttp.MatchString(path) { + return path + } + return fmt.Sprintf("/static/%s", path) +} -- cgit v1.2.3