From 6cd0784e447f18e009cbbf30de471e486f7cf356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sat, 8 Jun 2024 11:52:22 +0200 Subject: Implement defer Closes #8086 Closes #12589 --- resources/page/site.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'resources') diff --git a/resources/page/site.go b/resources/page/site.go index 56f438cb6..9f7871a02 100644 --- a/resources/page/site.go +++ b/resources/page/site.go @@ -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{ -- cgit v1.2.3