diff options
author | bep <bjorn.erik.pedersen@gmail.com> | 2015-01-19 02:53:07 +0100 |
---|---|---|
committer | bep <bjorn.erik.pedersen@gmail.com> | 2015-01-19 02:53:07 +0100 |
commit | 724357a2425354f85b80280c03da96175908eb01 (patch) | |
tree | a21a6b91de3f3d489da1e2d498297b7b71fbe921 /hugolib | |
parent | 109e6f95fdbb809b0a2759a06a1aac9d1cacc9b3 (diff) |
Make sure there are only one HugoInfo instance
See #570
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/hugo.go | 17 | ||||
-rw-r--r-- | hugolib/node.go | 6 |
2 files changed, 12 insertions, 11 deletions
diff --git a/hugolib/hugo.go b/hugolib/hugo.go index 24b09b2ee..3e4d02039 100644 --- a/hugolib/hugo.go +++ b/hugolib/hugo.go @@ -7,6 +7,8 @@ var ( BuildDate string ) +var hugoInfo *HugoInfo + // HugoInfo contains information about the current Hugo environment type HugoInfo struct { Version string @@ -15,11 +17,14 @@ type HugoInfo struct { BuildDate string } -func newHugoInfo() *HugoInfo { - return &HugoInfo{ - Version: Version, - CommitHash: CommitHash, - BuildDate: BuildDate, - Generator: `<meta name="generator" content="Hugo ` + Version + `" />`, +func getHugoInfo() *HugoInfo { + if hugoInfo == nil { + hugoInfo = &HugoInfo{ + Version: Version, + CommitHash: CommitHash, + BuildDate: BuildDate, + Generator: `<meta name="generator" content="Hugo ` + Version + `" />`, + } } + return hugoInfo } diff --git a/hugolib/node.go b/hugolib/node.go index 8619b7c89..85cf6aeb6 100644 --- a/hugolib/node.go +++ b/hugolib/node.go @@ -29,7 +29,6 @@ type Node struct { Params map[string]interface{} Date time.Time Sitemap Sitemap - hugo *HugoInfo UrlPath } @@ -79,10 +78,7 @@ func (n *Node) IsMenuCurrent(menuId string, inme *MenuEntry) bool { } func (n *Node) Hugo() *HugoInfo { - if n.hugo == nil { - n.hugo = newHugoInfo() - } - return n.hugo + return getHugoInfo() } func (n *Node) isSameAsDescendantMenu(inme *MenuEntry, parent *MenuEntry) bool { |