Implement defer

Closes #8086
Closes #12589
This commit is contained in:
Bjørn Erik Pedersen
2024-06-08 11:52:22 +02:00
parent 8731d88222
commit 6cd0784e44
33 changed files with 1033 additions and 148 deletions

View File

@@ -134,6 +134,12 @@ type Site interface {
// Deprecated: Use .Site.Home.OutputFormats.Get "rss" instead.
RSSLink() template.URL
// For internal use only.
// This will panic if the site is not fully initialized.
// This is typically used to inform the user in the content adapter templates,
// as these are executed before all the page collections etc. are ready to use.
CheckReady()
}
// Sites represents an ordered list of sites (languages).
@@ -326,6 +332,11 @@ func (s *siteWrapper) ForEeachIdentityByName(name string, f func(identity.Identi
s.s.(identity.ForEeachIdentityByNameProvider).ForEeachIdentityByName(name, f)
}
// For internal use only.
func (s *siteWrapper) CheckReady() {
s.s.CheckReady()
}
type testSite struct {
h hugo.HugoInfo
l *langs.Language
@@ -480,6 +491,9 @@ func (s testSite) RSSLink() template.URL {
return ""
}
func (s testSite) CheckReady() {
}
// NewDummyHugoSite creates a new minimal test site.
func NewDummyHugoSite(conf config.AllProvider) Site {
return testSite{