hugo/resources/page
Paul Gottschling 25d645f47a
Fix missing page data for alternative formats
When a template calls the .Translations function and a
Hugo environment is using multiple output formats,
a template that calls methods like .Summary and .Len on
each translation will unexpectedly show empty return
values for these methods.

This is because each pageOutput's ContentProvider is
assigned to a page.NopPage in newPageOutput. When
*HugoSites.render assigns pageContentOutputs to
pageOutputs in *pageState.shiftToOutputFormat, it
reuses pageContentOutputs from other pageOutputs,
leaving some pageContentOutputs as NopPages. While this
approach conserves resources, sometimes it means that
a template will unexpectedly call a method on a
pageContentOutput that is actually a NopPage.

In the case of ContentProvider methods called on
translations for alternative output formats, the methods
were called on NopPages.

This change introduces LazyContentProvider, which
performs late initialization when one of its methods is
called. This way, we can reuse content in "normal" cases
but ensure that ContentProvider methods work as expected
when a pageOutput is not assigned a pageContentOutput
during the initial pre-render phase.

Fixes #8919
2022-01-12 07:45:53 +01:00
..
page_generate Make the deprecated Page/File methods (from Hugo 0.55) ERROR 2022-01-04 17:10:39 +01:00
pagemeta
page.go Misc depreation updates 2022-01-04 17:10:39 +01:00
page_author.go
page_data.go
page_data_test.go
page_kinds.go
page_kinds_test.go
page_lazy_contentprovider.go Fix missing page data for alternative formats 2022-01-12 07:45:53 +01:00
page_marshaljson.autogen.go Misc depreation updates 2022-01-04 17:10:39 +01:00
page_matcher.go Misc depreation updates 2022-01-04 17:10:39 +01:00
page_matcher_test.go
page_nop.go Misc depreation updates 2022-01-04 17:10:39 +01:00
page_outputformat.go
page_paths.go
page_paths_test.go
page_wrappers.autogen.go Make the deprecated Page/File methods (from Hugo 0.55) ERROR 2022-01-04 17:10:39 +01:00
pagegroup.go
pagegroup_test.go
pages.go
pages_cache.go
pages_cache_test.go
pages_language_merge.go
pages_prev_next.go
pages_prev_next_test.go
pages_related.go
pages_related_test.go
pages_sort.go
pages_sort_search.go
pages_sort_search_test.go
pages_sort_test.go
pages_test.go
pagination.go
pagination_test.go
permalinks.go
permalinks_test.go
site.go Add hugo.Deps 2022-01-11 18:06:23 +01:00
testhelpers_test.go Misc depreation updates 2022-01-04 17:10:39 +01:00
weighted.go
zero_file.autogen.go Make the deprecated Page/File methods (from Hugo 0.55) ERROR 2022-01-04 17:10:39 +01:00