diff options
author | Bjørn Erik Pedersen <[email protected]> | 2023-03-04 14:43:23 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-03-04 17:19:14 +0100 |
commit | 6c798eba607a7e019cc1dfce6fd68be7f770c5bd (patch) | |
tree | deb10a398953f85ecc509585934fe4e0e8445e55 /resources | |
parent | ec1c97e7e9d62ce5245135e0906fdedf14af0cae (diff) | |
download | hugo-6c798eba607a7e019cc1dfce6fd68be7f770c5bd.tar.gz hugo-6c798eba607a7e019cc1dfce6fd68be7f770c5bd.zip |
Page context handling in i18n
This is a workaround. We need to improve on this, but not today.
Fixes #10782
Diffstat (limited to 'resources')
-rw-r--r-- | resources/page/page.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/resources/page/page.go b/resources/page/page.go index 84153b8c6..8f89142b3 100644 --- a/resources/page/page.go +++ b/resources/page/page.go @@ -471,3 +471,45 @@ type DeprecatedWarningPageMethods any // This was emptied in Hugo 0.93.0. // Move here to trigger ERROR instead of WARNING. // TODO(bep) create wrappers and put into the Page once it has some methods. type DeprecatedErrorPageMethods any + +// PageWithContext is a Page with a context.Context. +type PageWithContext struct { + Page + Ctx context.Context +} + +func (p PageWithContext) Content() (any, error) { + return p.Page.Content(p.Ctx) +} + +func (p PageWithContext) Plain() string { + return p.Page.Plain(p.Ctx) +} + +func (p PageWithContext) PlainWords() []string { + return p.Page.PlainWords(p.Ctx) +} + +func (p PageWithContext) Summary() template.HTML { + return p.Page.Summary(p.Ctx) +} + +func (p PageWithContext) Truncated() bool { + return p.Page.Truncated(p.Ctx) +} + +func (p PageWithContext) FuzzyWordCount() int { + return p.Page.FuzzyWordCount(p.Ctx) +} + +func (p PageWithContext) WordCount() int { + return p.Page.WordCount(p.Ctx) +} + +func (p PageWithContext) ReadingTime() int { + return p.Page.ReadingTime(p.Ctx) +} + +func (p PageWithContext) Len() int { + return p.Page.Len(p.Ctx) +} |