package config

import "github.com/gohugoio/hugo/config"

Index

Variables

var (
	ValidConfigFileExtensions = []string{"toml", "yaml", "yml", "json"}
)

Functions

func FromFileToMap

func FromFileToMap(fs afero.Fs, filename string) (map[string]interface{}, error)

FromFileToMap is the same as FromFile, but it returns the config values as a simple map.

func GetStringSlicePreserveString

func GetStringSlicePreserveString(cfg Provider, key string) []string

GetStringSlicePreserveString returns a string slice from the given config and key. It differs from the GetStringSlice method in that if the config value is a string, we do not attempt to split it into fields.

func IsValidConfigFilename

func IsValidConfigFilename(filename string) bool

IsValidConfigFilename returns whether filename is one of the supported config formats in Hugo.

func RenameKeys

func RenameKeys(m map[string]interface{})

RenameKeys renames config keys in m recursively according to a global Hugo alias definition.

Types

type Provider

type Provider interface {
	GetString(key string) string
	GetInt(key string) int
	GetBool(key string) bool
	GetStringMap(key string) map[string]interface{}
	GetStringMapString(key string) map[string]string
	GetStringSlice(key string) []string
	Get(key string) interface{}
	Set(key string, value interface{})
	IsSet(key string) bool
}

Provider provides the configuration settings for Hugo.

func FromConfigString

func FromConfigString(config, configType string) (Provider, error)

FromConfigString creates a config from the given YAML, JSON or TOML config. This is useful in tests.

func FromFile

func FromFile(fs afero.Fs, filename string) (Provider, error)

FromFile loads the configuration from the given filename.

Source Files

configLoader.go configProvider.go

Directories

PathSynopsis
config/privacy
config/services
Version
v0.54.0
Published
Feb 1, 2019
Platform
darwin/amd64
Imports
7 packages
Last checked
30 minutes ago

Tools for package owners.