mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
commands: Make sure all language homes are always re-rendered in fast render mode
Fixes #4125
This commit is contained in:
@@ -31,8 +31,8 @@ type PathSpec struct {
|
||||
uglyURLs bool
|
||||
canonifyURLs bool
|
||||
|
||||
language *Language
|
||||
//StatsCounter *siteSta
|
||||
language *Language
|
||||
languages Languages
|
||||
|
||||
// pagination path handling
|
||||
paginatePath string
|
||||
@@ -85,9 +85,20 @@ func NewPathSpec(fs *hugofs.Fs, cfg config.Provider) (*PathSpec, error) {
|
||||
staticDirs = append(staticDirs, getStringOrStringSlice(cfg, "staticDir", i)...)
|
||||
}
|
||||
|
||||
var lang string
|
||||
var (
|
||||
lang string
|
||||
language *Language
|
||||
languages Languages
|
||||
)
|
||||
|
||||
if l, ok := cfg.(*Language); ok {
|
||||
language = l
|
||||
lang = l.Lang
|
||||
|
||||
}
|
||||
|
||||
if l, ok := cfg.Get("languagesSorted").(Languages); ok {
|
||||
languages = l
|
||||
}
|
||||
|
||||
ps := &PathSpec{
|
||||
@@ -98,6 +109,8 @@ func NewPathSpec(fs *hugofs.Fs, cfg config.Provider) (*PathSpec, error) {
|
||||
uglyURLs: cfg.GetBool("uglyURLs"),
|
||||
canonifyURLs: cfg.GetBool("canonifyURLs"),
|
||||
multilingual: cfg.GetBool("multilingual"),
|
||||
language: language,
|
||||
languages: languages,
|
||||
defaultContentLanguageInSubdir: cfg.GetBool("defaultContentLanguageInSubdir"),
|
||||
defaultContentLanguage: cfg.GetString("defaultContentLanguage"),
|
||||
paginatePath: cfg.GetString("paginatePath"),
|
||||
@@ -119,10 +132,6 @@ func NewPathSpec(fs *hugofs.Fs, cfg config.Provider) (*PathSpec, error) {
|
||||
|
||||
ps.PublishDir = publishDir
|
||||
|
||||
if language, ok := cfg.(*Language); ok {
|
||||
ps.language = language
|
||||
}
|
||||
|
||||
return ps, nil
|
||||
}
|
||||
|
||||
|
@@ -215,6 +215,23 @@ func (p *PathSpec) getLanguagePrefix() string {
|
||||
return currentLang
|
||||
}
|
||||
|
||||
// GetLangSubDir returns the given language's subdir if needed.
|
||||
func (p *PathSpec) GetLangSubDir(lang string) string {
|
||||
if !p.multilingual {
|
||||
return ""
|
||||
}
|
||||
|
||||
if p.languages.IsMultihost() {
|
||||
return ""
|
||||
}
|
||||
|
||||
if lang == "" || (lang == p.defaultContentLanguage && !p.defaultContentLanguageInSubdir) {
|
||||
return ""
|
||||
}
|
||||
|
||||
return lang
|
||||
}
|
||||
|
||||
// IsAbsURL determines whether the given path points to an absolute URL.
|
||||
func IsAbsURL(path string) bool {
|
||||
url, err := url.Parse(path)
|
||||
|
Reference in New Issue
Block a user