hugo

package
v0.125.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 26 Imported by: 21

Documentation

Index

Constants

View Source
const (
	EnvironmentDevelopment = "development"
	EnvironmentProduction  = "production"
)

Variables

View Source
var CurrentVersion = Version{
	Major:      0,
	Minor:      125,
	PatchLevel: 5,
	Suffix:     "",
}

CurrentVersion represents the current build version. This should be the only one.

View Source
var DartSassBinaryName string

DartSassBinaryName is the name of the Dart Sass binary to use. TODO(beop) find a better place for this.

View Source
var IsExtended = false

Functions

func BuildVersionString

func BuildVersionString() string

BuildVersionString creates a version string. This is what you see when running "hugo version".

func CompareVersion

func CompareVersion(version any) int

CompareVersion compares the given version string or number against the running Hugo version. It returns -1 if the given version is less than, 0 if equal and 1 if greater than the running version.

func Deprecate added in v0.120.0

func Deprecate(item, alternative string, version string)

Deprecate informs about a deprecation starting at the given version.

A deprecation typically needs a simple change in the template, but doing so will make the template incompatible with older versions. Theme maintainers generally want 1. No warnings or errors in the console when building a Hugo site. 2. Their theme to work for at least the last few Hugo versions.

func DeprecateLevel added in v0.120.0

func DeprecateLevel(item, alternative, version string, level logg.Level)

DeprecateLevel informs about a deprecation logging at the given level.

func GetDependencyList added in v0.83.0

func GetDependencyList() []string

GetDependencyList returns a sorted dependency list on the format package="version". It includes both Go dependencies and (a manually maintained) list of C(++) dependencies.

func GetDependencyListNonGo added in v0.108.0

func GetDependencyListNonGo() []string

GetDependencyListNonGo returns a list of non-Go dependencies.

func GetExecEnviron added in v0.70.0

func GetExecEnviron(workDir string, cfg config.AllProvider, fs afero.Fs) []string

GetExecEnviron creates and gets the common os/exec environment used in the external programs we interact with via os/exec, e.g. postcss.

func GoMinorVersion added in v0.56.0

func GoMinorVersion() int

func IsDartSassV2 added in v0.114.0

func IsDartSassV2() bool

func IsRunningAsTest added in v0.84.0

func IsRunningAsTest() bool

IsRunningAsTest reports whether we are running as a test.

Types

type ConfigProvider added in v0.112.0

type ConfigProvider interface {
	Environment() string
	Running() bool
	WorkingDir() string
	IsMultihost() bool
	IsMultilingual() bool
}

ConfigProvider represents the config options that are relevant for HugoInfo.

type Dependency added in v0.92.0

type Dependency struct {
	// Returns the path to this module.
	// This will either be the module path, e.g. "github.com/gohugoio/myshortcodes",
	// or the path below your /theme folder, e.g. "mytheme".
	Path string

	// The module version.
	Version string

	// Whether this dependency is vendored.
	Vendor bool

	// Time version was created.
	Time time.Time

	// In the dependency tree, this is the first module that defines this module
	// as a dependency.
	Owner *Dependency

	// Replaced by this dependency.
	Replace *Dependency
}

Dependency is a single dependency, which can be either a Hugo Module or a local theme.

type HugoInfo added in v0.112.0

type HugoInfo struct {
	CommitHash string
	BuildDate  string

	// The build environment.
	// Defaults are "production" (hugo) and "development" (hugo server).
	// This can also be set by the user.
	// It can be any string, but it will be all lower case.
	Environment string

	// version of go that the Hugo binary was built with
	GoVersion string
	// contains filtered or unexported fields
}

HugoInfo contains information about the current Hugo environment

func NewInfo

func NewInfo(conf ConfigProvider, deps []*Dependency) HugoInfo

NewInfo creates a new Hugo Info object.

func (HugoInfo) Deps added in v0.112.0

func (i HugoInfo) Deps() []*Dependency

Deps gets a list of dependencies for this Hugo build.

func (HugoInfo) Generator added in v0.112.0

func (i HugoInfo) Generator() template.HTML

Generator a Hugo meta generator HTML tag.

func (HugoInfo) IsDevelopment added in v0.120.0

func (i HugoInfo) IsDevelopment() bool

IsDevelopment reports whether the current running environment is "development".

func (HugoInfo) IsExtended added in v0.112.0

func (i HugoInfo) IsExtended() bool

IsExtended reports whether the Hugo binary is the extended version.

func (HugoInfo) IsMultiHost deprecated added in v0.123.8

func (i HugoInfo) IsMultiHost() bool

Deprecated: Use hugo.IsMultihost instead.

func (HugoInfo) IsMultihost added in v0.124.0

func (i HugoInfo) IsMultihost() bool

IsMultihost reports whether each configured language has a unique baseURL.

func (HugoInfo) IsMultilingual added in v0.124.0

func (i HugoInfo) IsMultilingual() bool

IsMultilingual reports whether there are two or more configured languages.

func (HugoInfo) IsProduction added in v0.112.0

func (i HugoInfo) IsProduction() bool

IsProduction reports whether the current running environment is "production".

func (HugoInfo) IsServer added in v0.120.0

func (i HugoInfo) IsServer() bool

IsServer reports whether the built-in server is running.

func (HugoInfo) Version added in v0.112.0

func (i HugoInfo) Version() VersionString

Version returns the current version as a comparable version string.

func (HugoInfo) WorkingDir added in v0.112.0

func (i HugoInfo) WorkingDir() string

WorkingDir returns the project working directory.

type Version

type Version struct {
	Major int

	Minor int

	// Increment this for bug releases
	PatchLevel int

	// HugoVersionSuffix is the suffix used in the Hugo version string.
	// It will be blank for release versions.
	Suffix string
}

Version represents the Hugo build version.

func MustParseVersion

func MustParseVersion(s string) Version

MustParseVersion parses a version string and panics if any error occurs.

func ParseVersion

func ParseVersion(s string) (Version, error)

ParseVersion parses a version string.

func (Version) Compare added in v0.99.1

func (h Version) Compare(other any) int

Compare implements the compare.Comparer interface.

func (Version) Next

func (v Version) Next() Version

Next returns the next Hugo release version.

func (Version) NextPatchLevel

func (v Version) NextPatchLevel(level int) Version

NextPatchLevel returns the next patch/bugfix Hugo version. This will be a patch increment on the previous Hugo version.

func (Version) Prev

func (v Version) Prev() Version

Prev returns the previous Hugo release version.

func (Version) ReleaseVersion

func (v Version) ReleaseVersion() Version

ReleaseVersion represents the release version.

func (Version) String

func (v Version) String() string

func (Version) Version

func (v Version) Version() VersionString

Version returns the Hugo version.

type VersionString

type VersionString string

VersionString represents a Hugo version string.

func (VersionString) Compare

func (h VersionString) Compare(other any) int

Compare implements the compare.Comparer interface.

func (VersionString) Eq

func (h VersionString) Eq(other any) bool

Eq implements the compare.Eqer interface.

func (VersionString) String

func (h VersionString) String() string

func (VersionString) Version added in v0.120.0

func (h VersionString) Version() Version

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL