about summary refs log tree commit diff stats
path: root/internal/server
diff options
context:
space:
mode:
Diffstat (limited to 'internal/server')
-rw-r--r--internal/server/server.go31
1 files changed, 15 insertions, 16 deletions
diff --git a/internal/server/server.go b/internal/server/server.go
index 556c660..02202ae 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -103,6 +103,13 @@ func New(runtimeConfig *Config) (*Server, error) {
 			return nil, err
 		}
 		runtimeConfig.Root = "website"
+	} else {
+		tmpdir, err := os.MkdirTemp("", "website")
+		if err != nil {
+			return nil, err
+		}
+		defer os.RemoveAll(tmpdir)
+		runtimeConfig.Root = tmpdir
 	}
 
 	config, err := cfg.GetConfig()
@@ -113,15 +120,14 @@ func New(runtimeConfig *Config) (*Server, error) {
 	listenAddress := net.JoinHostPort(runtimeConfig.ListenAddress, strconv.Itoa(runtimeConfig.Port))
 	top := http.NewServeMux()
 
+	builderConfig := builder.IOConfig{
+		Source:      "content",
+		Destination: runtimeConfig.Root,
+		Development: runtimeConfig.Development,
+	}
+
 	if runtimeConfig.Development {
 		applyDevModeOverrides(config, listenAddress)
-		builderConfig := builder.IOConfig{
-			Source:      "content",
-			Destination: runtimeConfig.Root,
-			BaseURL:     config.BaseURL,
-			Development: true,
-		}
-		rebuild(builderConfig, config)
 
 		liveReload := livereload.New()
 		top.Handle("/_/reload", liveReload)
@@ -147,22 +153,15 @@ func New(runtimeConfig *Config) (*Server, error) {
 		go fw.Start(func(filename string) {
 			rebuild(builderConfig, config)
 		})
-	} else {
-		builderConfig := builder.IOConfig{
-			Source:      "content",
-			Destination: runtimeConfig.Root,
-			BaseURL:     config.BaseURL,
-			Development: false,
-		}
-		rebuild(builderConfig, config)
 	}
 
+	rebuild(builderConfig, config)
+
 	loggingMux := http.NewServeMux()
 	mux, err := website.NewMux(config, runtimeConfig.Root)
 	if err != nil {
 		return nil, errors.Wrap(err, "could not create website mux")
 	}
-	log.Debug("binding main handler to", "host", listenAddress)
 
 	if runtimeConfig.Development || runtimeConfig.Redirect {
 		loggingMux.Handle(config.BaseURL.Hostname()+"/", mux)