diff options
Diffstat (limited to 'helpers/pathspec.go')
-rw-r--r-- | helpers/pathspec.go | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/helpers/pathspec.go b/helpers/pathspec.go index 0fc957b3b..ddc183380 100644 --- a/helpers/pathspec.go +++ b/helpers/pathspec.go @@ -16,6 +16,7 @@ package helpers import ( "fmt" + "github.com/spf13/hugo/config" "github.com/spf13/hugo/hugofs" ) @@ -26,11 +27,20 @@ type PathSpec struct { uglyURLs bool canonifyURLs bool - currentContentLanguage *Language + language *Language // pagination path handling paginatePath string + baseURL string + theme string + + // Directories + themesDir string + layoutDir string + workingDir string + staticDir string + // The PathSpec looks up its config settings in both the current language // and then in the global Viper config. // Some settings, the settings listed below, does not make sense to be set @@ -45,31 +55,35 @@ type PathSpec struct { } func (p PathSpec) String() string { - return fmt.Sprintf("PathSpec, language %q, prefix %q, multilingual: %T", p.currentContentLanguage.Lang, p.getLanguagePrefix(), p.multilingual) + return fmt.Sprintf("PathSpec, language %q, prefix %q, multilingual: %T", p.language.Lang, p.getLanguagePrefix(), p.multilingual) } -// NewPathSpec creats a new PathSpec from the given filesystems and ConfigProvider. -func NewPathSpec(fs *hugofs.Fs, config ConfigProvider) *PathSpec { - - currCl, ok := config.Get("currentContentLanguage").(*Language) +// NewPathSpec creats a new PathSpec from the given filesystems and Language. +func NewPathSpec(fs *hugofs.Fs, cfg config.Provider) *PathSpec { - if !ok { - // TODO(bep) globals - currCl = NewLanguage("en") + ps := &PathSpec{ + fs: fs, + disablePathToLower: cfg.GetBool("disablePathToLower"), + removePathAccents: cfg.GetBool("removePathAccents"), + uglyURLs: cfg.GetBool("uglyURLs"), + canonifyURLs: cfg.GetBool("canonifyURLs"), + multilingual: cfg.GetBool("multilingual"), + defaultContentLanguageInSubdir: cfg.GetBool("defaultContentLanguageInSubdir"), + defaultContentLanguage: cfg.GetString("defaultContentLanguage"), + paginatePath: cfg.GetString("paginatePath"), + baseURL: cfg.GetString("baseURL"), + themesDir: cfg.GetString("themesDir"), + layoutDir: cfg.GetString("layoutDir"), + workingDir: cfg.GetString("workingDir"), + staticDir: cfg.GetString("staticDir"), + theme: cfg.GetString("theme"), } - return &PathSpec{ - fs: fs, - disablePathToLower: config.GetBool("disablePathToLower"), - removePathAccents: config.GetBool("removePathAccents"), - uglyURLs: config.GetBool("uglyURLs"), - canonifyURLs: config.GetBool("canonifyURLs"), - multilingual: config.GetBool("multilingual"), - defaultContentLanguageInSubdir: config.GetBool("defaultContentLanguageInSubdir"), - defaultContentLanguage: config.GetString("defaultContentLanguage"), - currentContentLanguage: currCl, - paginatePath: config.GetString("paginatePath"), + if language, ok := cfg.(*Language); ok { + ps.language = language } + + return ps } // PaginatePath returns the configured root path used for paginator pages. |