From 7fdd2b95e20f322b0a47f63ff1010a04f47ce67b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 9 Apr 2021 07:28:27 +0200 Subject: [PATCH] Add hugo.IsExtended Fixes #8399 --- common/hugo/hugo.go | 4 ++++ common/hugo/hugo_test.go | 1 + docs/content/en/functions/hugo.md | 3 +++ 3 files changed, 8 insertions(+) diff --git a/common/hugo/hugo.go b/common/hugo/hugo.go index 67e8e40a6..1aae80776 100644 --- a/common/hugo/hugo.go +++ b/common/hugo/hugo.go @@ -71,6 +71,10 @@ func (i Info) IsProduction() bool { return i.Environment == EnvironmentProduction } +func (i Info) IsExtended() bool { + return IsExtended +} + // NewInfo creates a new Hugo Info object. func NewInfo(environment string) Info { if environment == "" { diff --git a/common/hugo/hugo_test.go b/common/hugo/hugo_test.go index 0862f36e7..0631be62c 100644 --- a/common/hugo/hugo_test.go +++ b/common/hugo/hugo_test.go @@ -32,6 +32,7 @@ func TestHugoInfo(t *testing.T) { c.Assert(hugoInfo.Environment, qt.Equals, "production") c.Assert(string(hugoInfo.Generator()), qt.Contains, fmt.Sprintf("Hugo %s", hugoInfo.Version())) c.Assert(hugoInfo.IsProduction(), qt.Equals, true) + c.Assert(hugoInfo.IsExtended(), qt.Equals, IsExtended) devHugoInfo := NewInfo("development") c.Assert(devHugoInfo.IsProduction(), qt.Equals, false) diff --git a/docs/content/en/functions/hugo.md b/docs/content/en/functions/hugo.md index 099a5fa96..78f5018c4 100644 --- a/docs/content/en/functions/hugo.md +++ b/docs/content/en/functions/hugo.md @@ -41,6 +41,9 @@ hugo.CommitHash hugo.BuildDate : the compile date of the current Hugo binary formatted with RFC 3339 e.g. `2002-10-02T10:00:00-05:00` +hugo.IsExtended {{< new-in "0.83.0" >}} +: whether this is the extended Hugo binary. + hugo.IsProduction : returns true if `hugo.Environment` is set to the production environment