resources/page: Pull internal Page methods into its own interface

So it doesn't get visible when passing it to `jsonify`.
This commit is contained in:
Bjørn Erik Pedersen 2024-05-02 10:41:58 +02:00
parent 4255d13d3e
commit c892e75fbc
No known key found for this signature in database
3 changed files with 9 additions and 3 deletions

View file

@ -67,6 +67,7 @@ type pageCommon struct {
page.InSectionPositioner page.InSectionPositioner
page.OutputFormatsProvider page.OutputFormatsProvider
page.PageMetaProvider page.PageMetaProvider
page.PageMetaInternalProvider
page.Positioner page.Positioner
page.RawContentProvider page.RawContentProvider
page.RelatedKeywordsProvider page.RelatedKeywordsProvider

View file

@ -184,6 +184,7 @@ func (h *HugoSites) newPage(m *pageMeta) (*pageState, *paths.Path, error) {
ResourceNameTitleProvider: m, ResourceNameTitleProvider: m,
ResourceParamsProvider: m, ResourceParamsProvider: m,
PageMetaProvider: m, PageMetaProvider: m,
PageMetaInternalProvider: m,
RelatedKeywordsProvider: m, RelatedKeywordsProvider: m,
OutputFormatsProvider: page.NopPage, OutputFormatsProvider: page.NopPage,
ResourceTypeProvider: pageTypesProvider, ResourceTypeProvider: pageTypesProvider,

View file

@ -225,9 +225,6 @@ type PageMetaProvider interface {
// to the source of this Page. It will be relative to any content root. // to the source of this Page. It will be relative to any content root.
Path() string Path() string
// This is for internal use only.
PathInfo() *paths.Path
// The slug, typically defined in front matter. // The slug, typically defined in front matter.
Slug() string Slug() string
@ -253,6 +250,12 @@ type PageMetaProvider interface {
Weight() int Weight() int
} }
// PageMetaInternalProvider provides internal page metadata.
type PageMetaInternalProvider interface {
// This is for internal use only.
PathInfo() *paths.Path
}
// PageRenderProvider provides a way for a Page to render content. // PageRenderProvider provides a way for a Page to render content.
type PageRenderProvider interface { type PageRenderProvider interface {
// Render renders the given layout with this Page as context. // Render renders the given layout with this Page as context.
@ -273,6 +276,7 @@ type PageWithoutContent interface {
RenderShortcodesProvider RenderShortcodesProvider
resource.Resource resource.Resource
PageMetaProvider PageMetaProvider
PageMetaInternalProvider
resource.LanguageProvider resource.LanguageProvider
// For pages backed by a file. // For pages backed by a file.