diff --git a/editorFiles.go b/editorFiles.go index 86a87ab..b30cae0 100644 --- a/editorFiles.go +++ b/editorFiles.go @@ -8,11 +8,21 @@ import ( ) func (a *goBlog) serveEditorFiles(w http.ResponseWriter, r *http.Request) { + blog := r.Context().Value(blogContextKey).(string) + // Get files files, err := a.mediaFiles() if err != nil { a.serveError(w, r, err.Error(), http.StatusInternalServerError) return } + // Check if files at all + if len(files) == 0 { + a.render(w, r, templateEditorFiles, &renderData{ + BlogString: blog, + Data: map[string]interface{}{}, + }) + return + } // Sort files time desc sort.Slice(files, func(i, j int) bool { return files[i].Time.After(files[j].Time) @@ -31,7 +41,6 @@ func (a *goBlog) serveEditorFiles(w http.ResponseWriter, r *http.Request) { return } // Serve HTML - blog := r.Context().Value(blogContextKey).(string) a.render(w, r, templateEditorFiles, &renderData{ BlogString: blog, Data: map[string]interface{}{