diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-09-07 16:07:10 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-09-07 22:06:44 +0300 |
commit | 4055c121847847d8bd6b95a928185daee065091b (patch) | |
tree | 6620f51e7e89aa7ff0a9a93361d640ee5b297fea /resources | |
parent | 3ba7c92530a80f2f04fe57705ab05c247a6e8437 (diff) |
Fix some change detection issues on server reloads
* Fix change detection when .GetPage/site.GetPage is used from shortcode
* Fix stale content for GetPage results with short name lookups on server reloads
Fixes #7623
Fixes #7624
Fixes #7625
Diffstat (limited to 'resources')
-rw-r--r-- | resources/page/page.go | 9 | ||||
-rw-r--r-- | resources/page/page_nop.go | 11 | ||||
-rw-r--r-- | resources/page/testhelpers_test.go | 10 |
3 files changed, 30 insertions, 0 deletions
diff --git a/resources/page/page.go b/resources/page/page.go index de417178f..0b402c4e7 100644 --- a/resources/page/page.go +++ b/resources/page/page.go @@ -18,8 +18,11 @@ package page import ( "html/template" + "github.com/gohugoio/hugo/identity" + "github.com/bep/gitmap" "github.com/gohugoio/hugo/config" + "github.com/gohugoio/hugo/tpl" "github.com/gohugoio/hugo/common/hugo" "github.com/gohugoio/hugo/common/maps" @@ -97,6 +100,9 @@ type GetPageProvider interface { // This will return nil when no page could be found, and will return // an error if the ref is ambiguous. GetPage(ref string) (Page, error) + + // GetPageWithTemplateInfo is for internal use only. + GetPageWithTemplateInfo(info tpl.Info, ref string) (Page, error) } // GitInfoProvider provides Git info. @@ -260,6 +266,9 @@ type PageWithoutContent interface { // e.g. GetTerms("categories") GetTerms(taxonomy string) Pages + // Used in change/dependency tracking. + identity.Provider + DeprecatedWarningPageMethods } diff --git a/resources/page/page_nop.go b/resources/page/page_nop.go index c24792157..293b399c7 100644 --- a/resources/page/page_nop.go +++ b/resources/page/page_nop.go @@ -19,7 +19,10 @@ import ( "html/template" "time" + "github.com/gohugoio/hugo/identity" + "github.com/gohugoio/hugo/hugofs/files" + "github.com/gohugoio/hugo/tpl" "github.com/gohugoio/hugo/hugofs" @@ -170,6 +173,10 @@ func (p *nopPage) GetPage(ref string) (Page, error) { return nil, nil } +func (p *nopPage) GetPageWithTemplateInfo(info tpl.Info, ref string) (Page, error) { + return nil, nil +} + func (p *nopPage) GetParam(key string) interface{} { return nil } @@ -484,3 +491,7 @@ func (p *nopPage) Weight() int { func (p *nopPage) WordCount() int { return 0 } + +func (p *nopPage) GetIdentity() identity.Identity { + return identity.NewPathIdentity("content", "foo/bar.md") +} diff --git a/resources/page/testhelpers_test.go b/resources/page/testhelpers_test.go index dcd37c41e..17a795a20 100644 --- a/resources/page/testhelpers_test.go +++ b/resources/page/testhelpers_test.go @@ -20,6 +20,8 @@ import ( "time" "github.com/gohugoio/hugo/hugofs/files" + "github.com/gohugoio/hugo/identity" + "github.com/gohugoio/hugo/tpl" "github.com/gohugoio/hugo/modules" @@ -218,6 +220,10 @@ func (p *testPage) GetPage(ref string) (Page, error) { panic("not implemented") } +func (p *testPage) GetPageWithTemplateInfo(info tpl.Info, ref string) (Page, error) { + panic("not implemented") +} + func (p *testPage) GetParam(key string) interface{} { panic("not implemented") } @@ -565,6 +571,10 @@ func (p *testPage) WordCount() int { panic("not implemented") } +func (p *testPage) GetIdentity() identity.Identity { + panic("not implemented") +} + func createTestPages(num int) Pages { pages := make(Pages, num) |