Skip to content

Commit

Permalink
resources/page: Pull internal Page methods into its own interface
Browse files Browse the repository at this point in the history
So it doesn't get visible when passing it to `jsonify`.
  • Loading branch information
bep committed May 2, 2024
1 parent 4255d13 commit c892e75
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions hugolib/page__common.go
Expand Up @@ -67,6 +67,7 @@ type pageCommon struct {
page.InSectionPositioner
page.OutputFormatsProvider
page.PageMetaProvider
page.PageMetaInternalProvider
page.Positioner
page.RawContentProvider
page.RelatedKeywordsProvider
Expand Down
1 change: 1 addition & 0 deletions hugolib/page__new.go
Expand Up @@ -184,6 +184,7 @@ func (h *HugoSites) newPage(m *pageMeta) (*pageState, *paths.Path, error) {
ResourceNameTitleProvider: m,
ResourceParamsProvider: m,
PageMetaProvider: m,
PageMetaInternalProvider: m,
RelatedKeywordsProvider: m,
OutputFormatsProvider: page.NopPage,
ResourceTypeProvider: pageTypesProvider,
Expand Down
10 changes: 7 additions & 3 deletions resources/page/page.go
Expand Up @@ -225,9 +225,6 @@ type PageMetaProvider interface {
// to the source of this Page. It will be relative to any content root.
Path() string

// This is for internal use only.
PathInfo() *paths.Path

// The slug, typically defined in front matter.
Slug() string

Expand All @@ -253,6 +250,12 @@ type PageMetaProvider interface {
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.
type PageRenderProvider interface {
// Render renders the given layout with this Page as context.
Expand All @@ -273,6 +276,7 @@ type PageWithoutContent interface {
RenderShortcodesProvider
resource.Resource
PageMetaProvider
PageMetaInternalProvider
resource.LanguageProvider

// For pages backed by a file.
Expand Down

0 comments on commit c892e75

Please sign in to comment.