Handle transient errors in config loading etc.

As in: Get the Kubernetes site to build with the new Hugo version.

Updates #10947
This commit is contained in:
Bjørn Erik Pedersen
2023-05-17 13:12:49 +02:00
parent 5251f015bf
commit 05542130ba
7 changed files with 96 additions and 5 deletions

View File

@@ -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 }}

View File

@@ -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")

View File

@@ -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)
}