diff --git a/editor.go b/editor.go index 830171b..02da6d4 100644 --- a/editor.go +++ b/editor.go @@ -8,10 +8,11 @@ import ( type editorJsJson struct { Page string ContentType string + BaseURL string Data template.JS } -func renderEditor(pageName, inputText, contentType string) (template.HTML, error) { +func renderEditor(pageName, inputText, contentType string, baseurl string) (template.HTML, error) { if contentType == "json" { t, err := template.ParseFiles("templates/editorjs.html") if err != nil { @@ -20,7 +21,7 @@ func renderEditor(pageName, inputText, contentType string) (template.HTML, error if inputText == "" { inputText = "null" } - data := editorJsJson{Page: pageName, Data: template.JS(inputText), ContentType: contentType} + data := editorJsJson{Page: pageName, Data: template.JS(inputText), ContentType: contentType, BaseURL: baseurl} var buf bytes.Buffer err = t.Execute(&buf, data) if err != nil { diff --git a/main.go b/main.go index 3a082f0..f48b157 100644 --- a/main.go +++ b/main.go @@ -384,7 +384,7 @@ func (h *editHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { var editor template.HTML if jsonEditor { - editor, err = renderEditor(page, pageText, "json") + editor, err = renderEditor(page, pageText, "json", *baseurl) if err != nil { http.Error(w, err.Error(), 500) return diff --git a/templates/editorjs.html b/templates/editorjs.html index 50b8d20..c786247 100644 --- a/templates/editorjs.html +++ b/templates/editorjs.html @@ -1 +1 @@ -
+