From 05542130ba0205d3d8d14575b7e49ed42a855b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 17 May 2023 13:12:49 +0200 Subject: Handle transient errors in config loading etc. As in: Get the Kubernetes site to build with the new Hugo version. Updates #10947 --- hugolib/config_test.go | 38 +++++++++++++++++++++++++++++++++++++- hugolib/site.go | 4 ++++ hugolib/site_new.go | 2 +- 3 files changed, 42 insertions(+), 2 deletions(-) (limited to 'hugolib') 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) } -- cgit v1.2.3