about summary refs log tree commit diff stats
path: root/internal/builder/builder.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/builder/builder.go')
-rw-r--r--internal/builder/builder.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/internal/builder/builder.go b/internal/builder/builder.go
index 4436151..177fa2f 100644
--- a/internal/builder/builder.go
+++ b/internal/builder/builder.go
@@ -86,7 +86,7 @@ func writerToFile(writer io.WriterTo, pathParts ...string) error {
 	return nil
 }
 
-func build(outDir string, config config.Config) (*Result, error) {
+func build(outDir string, config *config.Config) (*Result, error) {
 	log.Debug("output", "dir", outDir)
 	r := &Result{
 		Hashes: make([]string, 0),
@@ -252,16 +252,19 @@ func build(outDir string, config config.Config) (*Result, error) {
 	return r, nil
 }
 
-func BuildSite(ioConfig IOConfig) (*Result, error) {
-	config, err := config.GetConfig()
-	if err != nil {
-		return nil, errors.WithMessage(err, "could not get config")
+func BuildSite(ioConfig IOConfig, cfg *config.Config) (*Result, error) {
+	if cfg == nil {
+		var err error
+		cfg, err = config.GetConfig()
+		if err != nil {
+			return nil, errors.WithMessage(err, "could not get config")
+		}
 	}
-	config.InjectLiveReload = ioConfig.Development
+	cfg.InjectLiveReload = ioConfig.Development
 	compressFiles = !ioConfig.Development
 
 	templates.Setup()
 	loadCSS()
 
-	return build(ioConfig.Destination, *config)
+	return build(ioConfig.Destination, cfg)
 }