about summary refs log tree commit diff stats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/build/build.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/cmd/build/build.go b/cmd/build/build.go
index 1983e3c..0436c20 100644
--- a/cmd/build/build.go
+++ b/cmd/build/build.go
@@ -25,6 +25,7 @@ import (
 	"github.com/antchfx/xmlquery"
 	"github.com/antchfx/xpath"
 	mapset "github.com/deckarep/golang-set/v2"
+	iohelper "github.com/jf-tech/go-corelib/ios"
 	"github.com/pkg/errors"
 	"github.com/yuin/goldmark"
 	"github.com/yuin/goldmark/extension"
@@ -153,13 +154,18 @@ func layout(filename string, config config.Config, pageTitle string) (*goquery.D
 }
 
 func renderHTML(doc *goquery.Document) io.Reader {
-	r, w := io.Pipe()
+	r := bytes.NewBufferString("<!doctype html>\n")
+	// hello go? HTML 5 does not have self-closing tags
+	replacer := iohelper.NewBytesReplacingReader(r, []byte("/>"), []byte(" >"))
+
+	// TODO: return errors to main thread
 	go func() {
-		w.Write([]byte("<!doctype html>\n"))
-		goquery.Render(w, doc.Children())
-		defer w.Close()
+		err := goquery.Render(r, doc.Children())
+		if err != nil {
+			slog.Error("error rendering html", "error", err)
+		}
 	}()
-	return r
+	return replacer
 }
 
 func renderPost(post Post, config config.Config) (r io.Reader, err error) {