mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 23:12:10 -05:00
Adding IsNode & IsPage functions to Page & Node
This commit is contained in:
parent
b10dea2955
commit
aae1ff3c92
3 changed files with 20 additions and 0 deletions
|
@ -43,6 +43,8 @@ matter, content or derived from file location.
|
||||||
**.WordCount** The number of words in the content.<br>
|
**.WordCount** The number of words in the content.<br>
|
||||||
**.ReadingTime** The estimated time it takes to read the content in minutes.<br>
|
**.ReadingTime** The estimated time it takes to read the content in minutes.<br>
|
||||||
**.Weight** Assigned weight (in the front matter) to this content, used in sorting.<br>
|
**.Weight** Assigned weight (in the front matter) to this content, used in sorting.<br>
|
||||||
|
**.IsNode** Always false for pages.<br>
|
||||||
|
**.IsPage** Always true for page.<br>
|
||||||
**.Site** See site variables below<br>
|
**.Site** See site variables below<br>
|
||||||
|
|
||||||
## Page Params
|
## Page Params
|
||||||
|
@ -65,6 +67,8 @@ includes indexes, lists and the homepage.
|
||||||
**.Url** The relative url for this node.<br>
|
**.Url** The relative url for this node.<br>
|
||||||
**.RSSLink** Link to the indexes' rss link <br>
|
**.RSSLink** Link to the indexes' rss link <br>
|
||||||
**.Data** The data specific to this type of node.<br>
|
**.Data** The data specific to this type of node.<br>
|
||||||
|
**.IsNode** Always true for nodes.<br>
|
||||||
|
**.IsPage** Always false for nodes.<br>
|
||||||
**.Site** See site variables below<br>
|
**.Site** See site variables below<br>
|
||||||
|
|
||||||
## Site Variables
|
## Site Variables
|
||||||
|
|
|
@ -47,6 +47,14 @@ func (n *Node) RSSlink() template.HTML {
|
||||||
return n.RSSLink
|
return n.RSSLink
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *Node) IsNode() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Node) IsPage() bool {
|
||||||
|
return !n.IsNode()
|
||||||
|
}
|
||||||
|
|
||||||
type UrlPath struct {
|
type UrlPath struct {
|
||||||
Url string
|
Url string
|
||||||
Permalink template.HTML
|
Permalink template.HTML
|
||||||
|
|
|
@ -85,6 +85,14 @@ func (p *Page) Plain() string {
|
||||||
return p.plain
|
return p.plain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Page) IsNode() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Page) IsPage() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Page) setSummary() {
|
func (p *Page) setSummary() {
|
||||||
if bytes.Contains(p.rawContent, summaryDivider) {
|
if bytes.Contains(p.rawContent, summaryDivider) {
|
||||||
// If user defines split:
|
// If user defines split:
|
||||||
|
|
Loading…
Reference in a new issue