From aae1ff3c92b7371385c25e4274957f01f04688ec Mon Sep 17 00:00:00 2001 From: spf13 Date: Tue, 19 Aug 2014 21:27:13 -0400 Subject: [PATCH] Adding IsNode & IsPage functions to Page & Node --- docs/content/templates/variables.md | 4 ++++ hugolib/node.go | 8 ++++++++ hugolib/page.go | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/docs/content/templates/variables.md b/docs/content/templates/variables.md index 3cecf2169..f76a6465c 100644 --- 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.
**.ReadingTime** The estimated time it takes to read the content in minutes.
**.Weight** Assigned weight (in the front matter) to this content, used in sorting.
+**.IsNode** Always false for pages.
+**.IsPage** Always true for page.
**.Site** See site variables below
## Page Params @@ -65,6 +67,8 @@ includes indexes, lists and the homepage. **.Url** The relative url for this node.
**.RSSLink** Link to the indexes' rss link
**.Data** The data specific to this type of node.
+**.IsNode** Always true for nodes.
+**.IsPage** Always false for nodes.
**.Site** See site variables below
## Site Variables diff --git a/hugolib/node.go b/hugolib/node.go index 2ff8d40cd..724a3e8ee 100644 --- 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 diff --git a/hugolib/page.go b/hugolib/page.go index 5d399391f..9f29630ec 100644 --- 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: