Adding IsNode & IsPage functions to Page & Node - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit aae1ff3c92b7371385c25e4274957f01f04688ec
DIR parent b10dea2955093ef82ff8707c4bdbc442d3ae1edb
HTML Author: spf13 <steve.francia@gmail.com>
Date: Tue, 19 Aug 2014 21:27:13 -0400
Adding IsNode & IsPage functions to Page & Node
Diffstat:
M docs/content/templates/variables.md | 4 ++++
M hugolib/node.go | 8 ++++++++
M hugolib/page.go | 8 ++++++++
3 files changed, 20 insertions(+), 0 deletions(-)
---
DIR diff --git a/docs/content/templates/variables.md b/docs/content/templates/variables.md
@@ -43,6 +43,8 @@ matter, content or derived from file location.
**.WordCount** The number of words in the content.<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>
+**.IsNode** Always false for pages.<br>
+**.IsPage** Always true for page.<br>
**.Site** See site variables below<br>
## Page Params
@@ -65,6 +67,8 @@ includes indexes, lists and the homepage.
**.Url** The relative url for this node.<br>
**.RSSLink** Link to the indexes' rss link <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 Variables
DIR diff --git a/hugolib/node.go b/hugolib/node.go
@@ -47,6 +47,14 @@ func (n *Node) RSSlink() template.HTML {
return n.RSSLink
}
+func (n *Node) IsNode() bool {
+ return true
+}
+
+func (n *Node) IsPage() bool {
+ return !n.IsNode()
+}
+
type UrlPath struct {
Url string
Permalink template.HTML
DIR diff --git a/hugolib/page.go b/hugolib/page.go
@@ -85,6 +85,14 @@ func (p *Page) Plain() string {
return p.plain
}
+func (p *Page) IsNode() bool {
+ return false
+}
+
+func (p *Page) IsPage() bool {
+ return true
+}
+
func (p *Page) setSummary() {
if bytes.Contains(p.rawContent, summaryDivider) {
// If user defines split: