mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 07:18:54 +00:00
page: Add IsBranch and deprecate IsNode
IsNode's meaning was murky. Add IsBranch, defined as the set of branch node kinds (home, section, taxonomy, term), and make IsNode a deprecated alias for it. Fixes #11574 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -221,10 +221,15 @@ type PageMetaProvider interface {
|
||||
// The title used for links.
|
||||
LinkTitle() string
|
||||
|
||||
// IsNode returns whether this is an item of one of the list types in Hugo,
|
||||
// i.e. not a regular content
|
||||
// IsNode returns whether this is a branch node (e.g. a section).
|
||||
//
|
||||
// Deprecated: Use IsBranch or "not IsPage" instead.
|
||||
IsNode() bool
|
||||
|
||||
// IsBranch returns whether this is a branch node, i.e. a node that
|
||||
// can have descendants (home, section, taxonomy or term).
|
||||
IsBranch() bool
|
||||
|
||||
// IsPage returns whether this is a regular content
|
||||
IsPage() bool
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ func generateMarshalJSON(c *codegen.Inspector) error {
|
||||
"github.com/gohugoio/hugo/resources/page",
|
||||
// Exclusion regexps. Matches method names.
|
||||
`\bPage\b`,
|
||||
`\bIsNode\b`,
|
||||
)
|
||||
|
||||
fmt.Fprintf(f, `%s
|
||||
|
||||
@@ -26,7 +26,6 @@ func MarshalPageToJSON(p Page) ([]byte, error) {
|
||||
lastmod := p.Lastmod()
|
||||
publishDate := p.PublishDate()
|
||||
expiryDate := p.ExpiryDate()
|
||||
aliases := p.Aliases()
|
||||
bundleType := p.BundleType()
|
||||
description := p.Description()
|
||||
draft := p.Draft()
|
||||
@@ -36,10 +35,10 @@ func MarshalPageToJSON(p Page) ([]byte, error) {
|
||||
layout := p.Layout()
|
||||
linkTitle := p.LinkTitle()
|
||||
isNode := p.IsNode()
|
||||
isBranch := p.IsBranch()
|
||||
isPage := p.IsPage()
|
||||
path := p.Path()
|
||||
slug := p.Slug()
|
||||
lang := p.Lang()
|
||||
isSection := p.IsSection()
|
||||
section := p.Section()
|
||||
sitemap := p.Sitemap()
|
||||
@@ -51,7 +50,6 @@ func MarshalPageToJSON(p Page) ([]byte, error) {
|
||||
Lastmod time.Time
|
||||
PublishDate time.Time
|
||||
ExpiryDate time.Time
|
||||
Aliases []string
|
||||
BundleType string
|
||||
Description string
|
||||
Draft bool
|
||||
@@ -61,10 +59,10 @@ func MarshalPageToJSON(p Page) ([]byte, error) {
|
||||
Layout string
|
||||
LinkTitle string
|
||||
IsNode bool
|
||||
IsBranch bool
|
||||
IsPage bool
|
||||
Path string
|
||||
Slug string
|
||||
Lang string
|
||||
IsSection bool
|
||||
Section string
|
||||
Sitemap config.SitemapConfig
|
||||
@@ -75,7 +73,6 @@ func MarshalPageToJSON(p Page) ([]byte, error) {
|
||||
Lastmod: lastmod,
|
||||
PublishDate: publishDate,
|
||||
ExpiryDate: expiryDate,
|
||||
Aliases: aliases,
|
||||
BundleType: bundleType,
|
||||
Description: description,
|
||||
Draft: draft,
|
||||
@@ -85,10 +82,10 @@ func MarshalPageToJSON(p Page) ([]byte, error) {
|
||||
Layout: layout,
|
||||
LinkTitle: linkTitle,
|
||||
IsNode: isNode,
|
||||
IsBranch: isBranch,
|
||||
IsPage: isPage,
|
||||
Path: path,
|
||||
Slug: slug,
|
||||
Lang: lang,
|
||||
IsSection: isSection,
|
||||
Section: section,
|
||||
Sitemap: sitemap,
|
||||
|
||||
@@ -227,6 +227,10 @@ func (p *nopPage) IsNode() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *nopPage) IsBranch() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *nopPage) IsPage() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -281,6 +281,10 @@ func (p *testPage) IsNode() bool {
|
||||
panic("testpage: not implemented")
|
||||
}
|
||||
|
||||
func (p *testPage) IsBranch() bool {
|
||||
panic("testpage: not implemented")
|
||||
}
|
||||
|
||||
func (p *testPage) IsPage() bool {
|
||||
panic("testpage: not implemented")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user