Add page.Store

Fixes #9546
This commit is contained in:
Bjørn Erik Pedersen
2022-02-22 14:42:33 +01:00
parent 7732da9f93
commit e97d3c640f
6 changed files with 69 additions and 1 deletions

View File

@@ -261,7 +261,15 @@ type PageWithoutContent interface {
// Helper methods
ShortcodeInfoProvider
compare.Eqer
// Scratch returns a Scratch that can be used to store temporary state.
// Note that this Scratch gets reset on server rebuilds. See Store() for a variant that survives.
maps.Scratcher
// Store returns a Scratch that can be used to store temporary state.
// In contrast to Scratch(), this Scratch is not reset on server rebuilds.
Store() *maps.Scratch
RelatedKeywordsProvider
// GetTerms gets the terms of a given taxonomy,

View File

@@ -418,6 +418,10 @@ func (p *nopPage) Scratch() *maps.Scratch {
return nil
}
func (p *nopPage) Store() *maps.Scratch {
return nil
}
func (p *nopPage) RelatedKeywords(cfg related.IndexConfig) ([]related.Keyword, error) {
return nil, nil
}

View File

@@ -498,6 +498,10 @@ func (p *testPage) Scratch() *maps.Scratch {
panic("not implemented")
}
func (p *testPage) Store() *maps.Scratch {
panic("not implemented")
}
func (p *testPage) RelatedKeywords(cfg related.IndexConfig) ([]related.Keyword, error) {
v, err := p.Param(cfg.Name)
if err != nil {