summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorDerek Perkins <derek@derekperkins.com>2014-12-09 08:36:07 -0700
committerbep <bjorn.erik.pedersen@gmail.com>2015-01-19 01:22:23 +0100
commitac6b86aff8fe2ef8417c48074aadad6beea53052 (patch)
treee750cca04e36c3fc9c8ad5d62919aeb75b18417c /hugolib
parent90afe41e4943393a98a3f64409d7e8445c6a622d (diff)
Added top level .Hugo variable with version, commit and generator information + docs
Added Version, CommitHash and BuildDate to hugolib/hugo.go and used it in build Removed commitHash and buildDate from commands/version.go and used hugolib vars Removed getDateFormat function from commands/version.go Conflicts: README.md docs/content/templates/variables.md
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/hugo.go25
-rw-r--r--hugolib/node.go1
-rw-r--r--hugolib/site.go5
3 files changed, 31 insertions, 0 deletions
diff --git a/hugolib/hugo.go b/hugolib/hugo.go
new file mode 100644
index 000000000..67c048dfa
--- /dev/null
+++ b/hugolib/hugo.go
@@ -0,0 +1,25 @@
+package hugolib
+
+const Version = "0.13-DEV"
+
+var (
+ CommitHash string
+ BuildDate string
+)
+
+// Hugo contains all the information about the current Hugo environment
+type HugoInfo struct {
+ Version string
+ Generator string
+ CommitHash string
+ BuildDate string
+}
+
+func NewHugoInfo() HugoInfo {
+ return HugoInfo{
+ Version: Version,
+ CommitHash: CommitHash,
+ BuildDate: BuildDate,
+ Generator: `<meta name="generator" content="Hugo ` + Version + `" />`,
+ }
+}
diff --git a/hugolib/node.go b/hugolib/node.go
index d502de389..f6d583a65 100644
--- a/hugolib/node.go
+++ b/hugolib/node.go
@@ -29,6 +29,7 @@ type Node struct {
Params map[string]interface{}
Date time.Time
Sitemap Sitemap
+ Hugo *HugoInfo
UrlPath
}
diff --git a/hugolib/site.go b/hugolib/site.go
index b4af9e76c..058ccd663 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -67,6 +67,7 @@ type Site struct {
Taxonomies TaxonomyList
Source source.Input
Sections Taxonomy
+ Hugo HugoInfo
Info SiteInfo
Shortcodes map[string]ShortcodeFunc
Menus Menus
@@ -96,6 +97,7 @@ type SiteInfo struct {
Files []*source.File
Recent *Pages // legacy, should be identical to Pages
Menus *Menus
+ Hugo *HugoInfo
Title string
Author map[string]interface{}
LanguageCode string
@@ -339,6 +341,7 @@ func (s *Site) initialize() (err error) {
s.Menus = Menus{}
+ s.Hugo = NewHugoInfo()
s.initializeSiteInfo()
s.Shortcodes = make(map[string]ShortcodeFunc)
@@ -366,6 +369,7 @@ func (s *Site) initializeSiteInfo() {
Menus: &s.Menus,
Params: params,
Permalinks: permalinks,
+ Hugo: &s.Hugo,
}
}
@@ -1190,6 +1194,7 @@ func (s *Site) NewNode() *Node {
return &Node{
Data: make(map[string]interface{}),
Site: &s.Info,
+ Hugo: &s.Hugo,
}
}