Skip to content

Commit

Permalink
Add hugo.IsExtended
Browse files Browse the repository at this point in the history
Fixes #8399
  • Loading branch information
bep committed Apr 9, 2021
1 parent 3d5dbdc commit 7fdd2b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions common/hugo/hugo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down
1 change: 1 addition & 0 deletions common/hugo/hugo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions docs/content/en/functions/hugo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7fdd2b9

Please sign in to comment.