summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-05-17 13:12:49 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-05-17 22:13:29 +0200
commit05542130ba0205d3d8d14575b7e49ed42a855b9a (patch)
treebb94df8ba48b349bdcb18d254af51a38722bef13 /hugolib
parent5251f015bfff40b49f92f8855834d5682f925860 (diff)
Handle transient errors in config loading etc.
As in: Get the Kubernetes site to build with the new Hugo version. Updates #10947
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/config_test.go38
-rw-r--r--hugolib/site.go4
-rw-r--r--hugolib/site_new.go2
3 files changed, 42 insertions, 2 deletions
diff --git a/hugolib/config_test.go b/hugolib/config_test.go
index 93060134d..e27068da6 100644
--- a/hugolib/config_test.go
+++ b/hugolib/config_test.go
@@ -742,6 +742,42 @@ themeconfigdirparam: {{ site.Params.themeconfigdirparam }}
}
+func TestConfigOutputFormatDefinedInTheme(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+theme = "mytheme"
+[outputFormats]
+[outputFormats.myotherformat]
+baseName = 'myotherindex'
+mediaType = 'text/html'
+[outputs]
+ home = ['myformat']
+-- themes/mytheme/hugo.toml --
+[outputFormats]
+[outputFormats.myformat]
+baseName = 'myindex'
+mediaType = 'text/html'
+-- layouts/index.html --
+Home.
+
+
+
+`
+
+ b, err := NewIntegrationTestBuilder(
+ IntegrationTestConfig{
+ T: t,
+ TxtarString: files,
+ },
+ ).BuildE()
+
+ b.Assert(err, qt.IsNil)
+ b.AssertFileContent("public/myindex.html", "Home.")
+
+}
+
func TestReproCommentsIn10947(t *testing.T) {
t.Parallel()
@@ -768,7 +804,7 @@ title: "My Swedish Section"
---
-- layouts/index.html --
{{ range $i, $e := (slice site .Site) }}
-{{ $i }}|AllPages: {{ len .AllPages }}|Sections: {{ if .Sections }}true{{ end }}| Author: {{ .Authors }}|BuildDrafts: {{ .BuildDrafts }}|IsMultiLingual: {{ .IsMultiLingual }}|Param: {{ .Language.Params.myparam }}|
+{{ $i }}|AllPages: {{ len .AllPages }}|Sections: {{ if .Sections }}true{{ end }}| Author: {{ .Authors }}|BuildDrafts: {{ .BuildDrafts }}|IsMultiLingual: {{ .IsMultiLingual }}|Param: {{ .Language.Params.myparam }}|Language string: {{ .Language }}|Languages: {{ .Languages }}
{{ end }}
diff --git a/hugolib/site.go b/hugolib/site.go
index b055cf690..301d66dac 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -273,6 +273,10 @@ func (s *Site) Language() *langs.Language {
return s.language
}
+func (s *Site) Languages() langs.Languages {
+ return s.h.Configs.Languages
+}
+
func (s *Site) isEnabled(kind string) bool {
if kind == kindUnknown {
panic("Unknown kind")
diff --git a/hugolib/site_new.go b/hugolib/site_new.go
index 2b959a8da..b0b34e457 100644
--- a/hugolib/site_new.go
+++ b/hugolib/site_new.go
@@ -431,7 +431,7 @@ func (s *Site) GoogleAnalytics() string {
return s.Config().Services.GoogleAnalytics.ID
}
-func (s *Site) Param(key string) (any, error) {
+func (s *Site) Param(key any) (any, error) {
return resource.Param(s, nil, key)
}