mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
Rework the Destination filesystem to make --renderStaticToDisk work
See #9626
This commit is contained in:
@@ -18,6 +18,8 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
hpaths "github.com/gohugoio/hugo/common/paths"
|
||||
|
||||
"github.com/gohugoio/hugo/config"
|
||||
"github.com/gohugoio/hugo/langs"
|
||||
"github.com/gohugoio/hugo/modules"
|
||||
@@ -51,6 +53,7 @@ type Paths struct {
|
||||
// pagination path handling
|
||||
PaginatePath string
|
||||
|
||||
// TODO1 check usage
|
||||
PublishDir string
|
||||
|
||||
// When in multihost mode, this returns a list of base paths below PublishDir
|
||||
@@ -123,7 +126,7 @@ func New(fs *hugofs.Fs, cfg config.Provider) (*Paths, error) {
|
||||
languages = langs.Languages{&langs.Language{Lang: "en", Cfg: cfg, ContentDir: contentDir}}
|
||||
}
|
||||
|
||||
absPublishDir := AbsPathify(workingDir, publishDir)
|
||||
absPublishDir := hpaths.AbsPathify(workingDir, publishDir)
|
||||
if !strings.HasSuffix(absPublishDir, FilePathSeparator) {
|
||||
absPublishDir += FilePathSeparator
|
||||
}
|
||||
@@ -131,7 +134,7 @@ func New(fs *hugofs.Fs, cfg config.Provider) (*Paths, error) {
|
||||
if absPublishDir == "//" {
|
||||
absPublishDir = FilePathSeparator
|
||||
}
|
||||
absResourcesDir := AbsPathify(workingDir, resourceDir)
|
||||
absResourcesDir := hpaths.AbsPathify(workingDir, resourceDir)
|
||||
if !strings.HasSuffix(absResourcesDir, FilePathSeparator) {
|
||||
absResourcesDir += FilePathSeparator
|
||||
}
|
||||
@@ -254,7 +257,7 @@ func (p *Paths) GetLangSubDir(lang string) string {
|
||||
// AbsPathify creates an absolute path if given a relative path. If already
|
||||
// absolute, the path is just cleaned.
|
||||
func (p *Paths) AbsPathify(inPath string) string {
|
||||
return AbsPathify(p.WorkingDir, inPath)
|
||||
return hpaths.AbsPathify(p.WorkingDir, inPath)
|
||||
}
|
||||
|
||||
// RelPathify trims any WorkingDir prefix from the given filename. If
|
||||
@@ -267,12 +270,3 @@ func (p *Paths) RelPathify(filename string) string {
|
||||
|
||||
return strings.TrimPrefix(strings.TrimPrefix(filename, p.WorkingDir), FilePathSeparator)
|
||||
}
|
||||
|
||||
// AbsPathify creates an absolute path if given a working dir and a relative path.
|
||||
// If already absolute, the path is just cleaned.
|
||||
func AbsPathify(workingDir, inPath string) string {
|
||||
if filepath.IsAbs(inPath) {
|
||||
return filepath.Clean(inPath)
|
||||
}
|
||||
return filepath.Join(workingDir, inPath)
|
||||
}
|
||||
|
Reference in New Issue
Block a user