diff --git a/builder_suite_test.go b/builder_suite_test.go
index eb0965d..552fc44 100644
--- a/builder_suite_test.go
+++ b/builder_suite_test.go
@@ -175,23 +175,23 @@ title: required
contents := readFile("index.html")
Eventually(contents).ShouldNot(gbytes.Say(`IGNORE ME`))
- Eventually(contents).Should(gbytes.Say(`some 10 😂 title 10`))
- Eventually(contents).Should(gbytes.Say(`some 10 😂 title 10`))
- Eventually(contents).Should(gbytes.Say(`some 9 😂 title`))
- Eventually(contents).Should(gbytes.Say(`some 8 😂 title`))
- Eventually(contents).ShouldNot(gbytes.Say(`some 7 😂 title`))
+ Eventually(contents).Should(gbytes.Say(`some 10 😂 title 10`))
+ Eventually(contents).Should(gbytes.Say(`some 10 😂 title 10`))
+ Eventually(contents).Should(gbytes.Say(`some 9 😂 title`))
+ Eventually(contents).Should(gbytes.Say(`some 8 😂 title`))
+ Eventually(contents).ShouldNot(gbytes.Say(`some 7 😂 title`))
contents = readFile("index-all.html")
- Eventually(contents).Should(gbytes.Say(`some 10 😂 title`))
- Eventually(contents).Should(gbytes.Say(`some 9 😂 title`))
- Eventually(contents).Should(gbytes.Say(`some 8 😂 title`))
- Eventually(contents).Should(gbytes.Say(`some 7 😂 title`))
- Eventually(contents).Should(gbytes.Say(`some 6 😂 title`))
- Eventually(contents).Should(gbytes.Say(`some 5 😂 title`))
- Eventually(contents).Should(gbytes.Say(`some 4 😂 title`))
- Eventually(contents).Should(gbytes.Say(`some 3 😂 title`))
- Eventually(contents).Should(gbytes.Say(`some 2 😂 title`))
- Eventually(contents).Should(gbytes.Say(`some 1 😂 title`))
+ Eventually(contents).Should(gbytes.Say(`some 10 😂 title`))
+ Eventually(contents).Should(gbytes.Say(`some 9 😂 title`))
+ Eventually(contents).Should(gbytes.Say(`some 8 😂 title`))
+ Eventually(contents).Should(gbytes.Say(`some 7 😂 title`))
+ Eventually(contents).Should(gbytes.Say(`some 6 😂 title`))
+ Eventually(contents).Should(gbytes.Say(`some 5 😂 title`))
+ Eventually(contents).Should(gbytes.Say(`some 4 😂 title`))
+ Eventually(contents).Should(gbytes.Say(`some 3 😂 title`))
+ Eventually(contents).Should(gbytes.Say(`some 2 😂 title`))
+ Eventually(contents).Should(gbytes.Say(`some 1 😂 title`))
})
})
@@ -235,7 +235,7 @@ title: required
buffer := gbytes.BufferWithBytes(contents)
- Eventually(buffer).Should(gbytes.Say(`
h2 Heading
`))
+ Eventually(buffer).Should(gbytes.Say(`h2 Heading
`))
})
})
})
diff --git a/go.mod b/go.mod
index a94036e..bb9ada0 100644
--- a/go.mod
+++ b/go.mod
@@ -13,6 +13,7 @@ require (
github.com/onsi/gomega v1.27.10
github.com/otiai10/copy v1.12.0
github.com/samber/lo v1.38.1
+ github.com/tdewolff/minify v2.3.6+incompatible
github.com/yuin/goldmark v1.5.6
github.com/yuin/goldmark-emoji v1.0.2
github.com/yuin/goldmark-highlighting v0.0.0-20220208100518-594be1970594
@@ -34,6 +35,8 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/stretchr/testify v1.8.2 // indirect
+ github.com/tdewolff/parse v2.3.4+incompatible // indirect
+ github.com/tdewolff/test v1.0.9 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
golang.org/x/crypto v0.12.0 // indirect
diff --git a/go.sum b/go.sum
index 59b23be..9a65607 100644
--- a/go.sum
+++ b/go.sum
@@ -66,6 +66,12 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
+github.com/tdewolff/minify v2.3.6+incompatible h1:2hw5/9ZvxhWLvBUnHE06gElGYz+Jv9R4Eys0XUzItYo=
+github.com/tdewolff/minify v2.3.6+incompatible/go.mod h1:9Ov578KJUmAWpS6NeZwRZyT56Uf6o3Mcz9CEsg8USYs=
+github.com/tdewolff/parse v2.3.4+incompatible h1:x05/cnGwIMf4ceLuDMBOdQ1qGniMoxpP46ghf0Qzh38=
+github.com/tdewolff/parse v2.3.4+incompatible/go.mod h1:8oBwCsVmUkgHO8M5iCzSIDtpzXOT0WXX9cWhz+bIzJQ=
+github.com/tdewolff/test v1.0.9 h1:SswqJCmeN4B+9gEAi/5uqT0qpi1y2/2O47V/1hhGZT0=
+github.com/tdewolff/test v1.0.9/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
diff --git a/render.go b/render.go
index 569e4cf..2f3ee86 100644
--- a/render.go
+++ b/render.go
@@ -12,6 +12,8 @@ import (
"github.com/gosimple/slug"
cp "github.com/otiai10/copy"
"github.com/samber/lo"
+ "github.com/tdewolff/minify"
+ mHTML "github.com/tdewolff/minify/html"
"github.com/yuin/goldmark"
emoji "github.com/yuin/goldmark-emoji"
highlighting "github.com/yuin/goldmark-highlighting"
@@ -209,8 +211,15 @@ func writeHTMLFiles(filenames []string, contents string) error {
return fmt.Errorf("could not create path (%s): %w", dirPath, err)
}
+ writer := &strings.Builder{}
+
+ err = mHTML.Minify(&minify.M{}, writer, strings.NewReader(contents), nil)
+ if err != nil {
+ return fmt.Errorf("could not minify: %w", err)
+ }
+
for _, filename := range filenames {
- err = os.WriteFile(filename, []byte(contents), os.ModePerm)
+ err = os.WriteFile(filename, []byte(writer.String()), os.ModePerm)
if err != nil {
return fmt.Errorf("could not write path (%s): %w", filename, err)
}