aboutsummaryrefslogtreecommitdiffhomepage
path: root/config
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2023-07-07 18:41:10 +0200
committerBjørn Erik Pedersen <[email protected]>2023-07-08 16:08:46 +0200
commit92e86702eab5d68cd4eda87069fba906139f5c08 (patch)
tree6edb31f509cb321b3ab9d038bfd6d50ea07f6fac /config
parent6c9ea022a9022a281031eed75ceb00c4c03f2b5a (diff)
downloadhugo-92e86702eab5d68cd4eda87069fba906139f5c08.tar.gz
hugo-92e86702eab5d68cd4eda87069fba906139f5c08.zip
Fix defaultContentLanguageInSubdir with only 1 language
Fixes #10064
Diffstat (limited to 'config')
-rw-r--r--config/allconfig/configlanguage.go10
-rw-r--r--config/configProvider.go1
2 files changed, 11 insertions, 0 deletions
diff --git a/config/allconfig/configlanguage.go b/config/allconfig/configlanguage.go
index be549126b..534276c25 100644
--- a/config/allconfig/configlanguage.go
+++ b/config/allconfig/configlanguage.go
@@ -41,6 +41,16 @@ func (c ConfigLanguage) LanguagesDefaultFirst() langs.Languages {
return c.m.LanguagesDefaultFirst
}
+func (c ConfigLanguage) LanguagePrefix() string {
+ if c.DefaultContentLanguageInSubdir() && c.DefaultContentLanguage() == c.Language().Lang {
+ return c.Language().Lang
+ }
+ if !c.IsMultiLingual() || c.DefaultContentLanguage() == c.Language().Lang {
+ return ""
+ }
+ return c.Language().Lang
+}
+
func (c ConfigLanguage) BaseURL() urls.BaseURL {
return c.config.C.BaseURL
}
diff --git a/config/configProvider.go b/config/configProvider.go
index 5d6acce9f..946830056 100644
--- a/config/configProvider.go
+++ b/config/configProvider.go
@@ -27,6 +27,7 @@ type AllProvider interface {
Language() *langs.Language
Languages() langs.Languages
LanguagesDefaultFirst() langs.Languages
+ LanguagePrefix() string
BaseURL() urls.BaseURL
BaseURLLiveReload() urls.BaseURL
Environment() string