summaryrefslogtreecommitdiffstats
path: root/commands/server.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-21 09:35:15 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-04-08 13:26:17 +0200
commitd070bdf10f14d233288f7318a4e9f7555f070a65 (patch)
treefff8d59f98bdab3027bb45c4e10ca88594332872 /commands/server.go
parentb08193971a821fc27e549a73120c15e5e5186775 (diff)
Rework the Destination filesystem to make --renderStaticToDisk work
See #9626
Diffstat (limited to 'commands/server.go')
-rw-r--r--commands/server.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/commands/server.go b/commands/server.go
index da1918ede..145a889bb 100644
--- a/commands/server.go
+++ b/commands/server.go
@@ -23,6 +23,7 @@ import (
"net/url"
"os"
"os/signal"
+ "path"
"path/filepath"
"regexp"
"runtime"
@@ -148,7 +149,7 @@ func (sc *serverCmd) server(cmd *cobra.Command, args []string) error {
var serverCfgInit sync.Once
cfgInit := func(c *commandeer) (rerr error) {
- c.Set("renderToMemory", !sc.renderToDisk)
+ c.Set("renderToMemory", !(sc.renderToDisk || sc.renderStaticToDisk))
c.Set("renderStaticToDisk", sc.renderStaticToDisk)
if cmd.Flags().Changed("navigateToChanged") {
c.Set("navigateToChanged", sc.navigateToChanged)
@@ -330,13 +331,18 @@ func (f *fileServer) createEndpoint(i int) (*http.ServeMux, net.Listener, string
port := f.c.serverPorts[i].p
listener := f.c.serverPorts[i].ln
+ // For logging only.
+ // TODO(bep) consolidate.
publishDir := f.c.Cfg.GetString("publishDir")
+ publishDirStatic := f.c.Cfg.GetString("publishDirStatic")
+ workingDir := f.c.Cfg.GetString("workingDir")
if root != "" {
publishDir = filepath.Join(publishDir, root)
+ publishDirStatic = filepath.Join(publishDirStatic, root)
}
-
- absPublishDir := f.c.hugo().PathSpec.AbsPathify(publishDir)
+ absPublishDir := paths.AbsPathify(workingDir, publishDir)
+ absPublishDirStatic := paths.AbsPathify(workingDir, publishDirStatic)
jww.FEEDBACK.Printf("Environment: %q", f.c.hugo().Deps.Site.Hugo().Environment)
@@ -344,14 +350,14 @@ func (f *fileServer) createEndpoint(i int) (*http.ServeMux, net.Listener, string
if f.s.renderToDisk {
jww.FEEDBACK.Println("Serving pages from " + absPublishDir)
} else if f.s.renderStaticToDisk {
- jww.FEEDBACK.Println("Serving pages from memory and static files from " + absPublishDir)
+ jww.FEEDBACK.Println("Serving pages from memory and static files from " + absPublishDirStatic)
} else {
jww.FEEDBACK.Println("Serving pages from memory")
}
}
- httpFs := afero.NewHttpFs(f.c.destinationFs)
- fs := filesOnlyFs{httpFs.Dir(absPublishDir)}
+ httpFs := afero.NewHttpFs(f.c.publishDirServerFs)
+ fs := filesOnlyFs{httpFs.Dir(path.Join("/", root))}
if i == 0 && f.c.fastRenderMode {
jww.FEEDBACK.Println("Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender")