mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-31 22:41:53 +02:00
Add Page.Contents with scope support
Note that this also adds a new `.ContentWithoutSummary` method, and to do that we had to unify the different summary types: Both `auto` and `manual` now returns HTML. Before this commit, `auto` would return plain text. This could be considered to be a slightly breaking change, but for the better: Now you can treat the `.Summary` the same without thinking about where it comes from, and if you want plain text, pipe it into `{{ .Summary | plainify }}`. Fixes #8680 Fixes #12761 Fixes #12778 Fixes #716
This commit is contained in:
@@ -74,10 +74,17 @@ type ChildCareProvider interface {
|
||||
Resources() resource.Resources
|
||||
}
|
||||
|
||||
type MarkupProvider interface {
|
||||
Markup(opts ...any) Markup
|
||||
}
|
||||
|
||||
// ContentProvider provides the content related values for a Page.
|
||||
type ContentProvider interface {
|
||||
Content(context.Context) (any, error)
|
||||
|
||||
// ContentWithoutSummary returns the Page Content stripped of the summary.
|
||||
ContentWithoutSummary(ctx context.Context) (template.HTML, error)
|
||||
|
||||
// Plain returns the Page Content stripped of HTML markup.
|
||||
Plain(context.Context) string
|
||||
|
||||
@@ -169,6 +176,7 @@ type PageProvider interface {
|
||||
|
||||
// Page is the core interface in Hugo and what you get as the top level data context in your templates.
|
||||
type Page interface {
|
||||
MarkupProvider
|
||||
ContentProvider
|
||||
TableOfContentsProvider
|
||||
PageWithoutContent
|
||||
@@ -260,7 +268,7 @@ type PageMetaInternalProvider interface {
|
||||
type PageRenderProvider interface {
|
||||
// Render renders the given layout with this Page as context.
|
||||
Render(ctx context.Context, layout ...string) (template.HTML, error)
|
||||
// RenderString renders the first value in args with tPaginatorhe content renderer defined
|
||||
// RenderString renders the first value in args with the content renderer defined
|
||||
// for this Page.
|
||||
// It takes an optional map as a second argument:
|
||||
//
|
||||
|
Reference in New Issue
Block a user