valueobject

package
v0.0.0-...-f0d32e8 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilecacheRootDirname = "filecache"
)

Variables

View Source
var DefaultModuleConfig = ModuleConfig{
	Mounts:  make([]Mount, 0),
	Imports: make([]Import, 0),
}
View Source
var DefaultSecurityConfig = SecurityConfig{
	Auth: hexec.Auth{
		Allow: security.MustNewWhitelist(
			"^(dart-)?sass(-embedded)?$",
			"^go$",
			"^npx$",
			"^postcss$",
		),

		OsEnv: security.MustNewWhitelist(`(?i)^((HTTPS?|NO)_PROXY|PATH(EXT)?|APPDATA|TE?MP|TERM|GO\w+|(XDG_CONFIG_)?HOME|USERPROFILE|SSH_AUTH_SOCK|DISPLAY|LANG|SYSTEMDRIVE)$`),
	},
	Funcs: Funcs{
		Getenv: security.MustNewWhitelist("^HUGO_", "^CI$"),
	},
	HTTP: HTTP{
		URLs:    security.MustNewWhitelist(".*"),
		Methods: security.MustNewWhitelist("(?i)GET|POST"),
	},
}

DefaultSecurityConfig holds the default security policy.

Functions

func CheckConfigFilename

func CheckConfigFilename(dir string, fs afero.Fs) (string, bool)

func DecodeLanguageConfig

func DecodeLanguageConfig(p config.Provider) (map[string]LanguageConfig, error)

func FromFile

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

FromFile loads the configuration from the given filename.

func GetCacheDir

func GetCacheDir(fs afero.Fs, cacheDir string) (string, error)

GetCacheDir returns a cache dir from the given filesystem and config. The dir will be created if it does not exist.

func LoadConfigFromFile

func LoadConfigFromFile(fs afero.Fs, filename string) (map[string]any, error)

func NewDefaultProvider

func NewDefaultProvider() config.Provider

NewDefaultProvider creates a Provider backed by an empty maps.Params.

func NewFrom

func NewFrom(params maps.Params) config.Provider

NewFrom creates a Provider backed by params.

Types

type BaseDirs

type BaseDirs struct {
	WorkingDir string
	ThemesDir  string
	PublishDir string
	CacheDir   string
}

type CachesConfig

type CachesConfig map[string]FileCacheConfig

func DecodeCachesConfig

func DecodeCachesConfig(fs afero.Fs, p config.Provider, bcfg BaseDirs) (CachesConfig, error)

func (CachesConfig) CacheDirModules

func (c CachesConfig) CacheDirModules() string

type CommonDirs

type CommonDirs struct {
	BaseDirs `mapstructure:",squash"`

	// The directory to put the generated resources files. This directory should in most situations be considered temporary
	// and not be committed to version control. But there may be cached content in here that you want to keep,
	// e.g. resources/_gen/images for performance reasons or CSS built from SASS when your CI server doesn't have the full setup.
	ResourceDir string

	// The content source directory.
	ContentDir string
	// The data source directory.
	DataDir string
	// The layout source directory.
	LayoutDir string
	// The i18n source directory.
	I18nDir string
	// The archetypes source directory.
	ArcheTypeDir string
	// The assets source directory.
	AssetDir string
}

func (CommonDirs) GetDirectoryByName

func (dirs CommonDirs) GetDirectoryByName(folderName string) string

type Component

type Component struct {
	ComName string
	ComDir  string
	ComLang string
}

func (*Component) Dir

func (c *Component) Dir() string

func (*Component) Language

func (c *Component) Language() string

func (*Component) Name

func (c *Component) Name() string

type DefaultConfigProvider

type DefaultConfigProvider struct {
	Root maps.Params
	// contains filtered or unexported fields
}

DefaultConfigProvider is a Provider backed by a map where all keys are lower case. All methods are thread safe.

func (*DefaultConfigProvider) Get

func (c *DefaultConfigProvider) Get(k string) any

func (*DefaultConfigProvider) GetBool

func (c *DefaultConfigProvider) GetBool(k string) bool

func (*DefaultConfigProvider) GetInt

func (c *DefaultConfigProvider) GetInt(k string) int

func (*DefaultConfigProvider) GetParams

func (c *DefaultConfigProvider) GetParams(k string) maps.Params

func (*DefaultConfigProvider) GetString

func (c *DefaultConfigProvider) GetString(k string) string

func (*DefaultConfigProvider) GetStringMap

func (c *DefaultConfigProvider) GetStringMap(k string) map[string]any

func (*DefaultConfigProvider) GetStringMapString

func (c *DefaultConfigProvider) GetStringMapString(k string) map[string]string

func (*DefaultConfigProvider) GetStringSlice

func (c *DefaultConfigProvider) GetStringSlice(k string) []string

func (*DefaultConfigProvider) IsSet

func (c *DefaultConfigProvider) IsSet(k string) bool

func (*DefaultConfigProvider) Keys

func (c *DefaultConfigProvider) Keys() []string

func (*DefaultConfigProvider) Merge

func (c *DefaultConfigProvider) Merge(k string, v any)

func (*DefaultConfigProvider) Set

func (c *DefaultConfigProvider) Set(k string, v any)

func (*DefaultConfigProvider) SetDefaultMergeStrategy

func (c *DefaultConfigProvider) SetDefaultMergeStrategy()

func (*DefaultConfigProvider) SetDefaults

func (c *DefaultConfigProvider) SetDefaults(params maps.Params)

SetDefaults will set values from params if not already set.

func (*DefaultConfigProvider) WalkParams

func (c *DefaultConfigProvider) WalkParams(walkFn func(params ...maps.KeyParams) bool)

type ExifConfig

type ExifConfig struct {
	// Regexp matching the Exif fields you want from the (massive) set of Exif info
	// available. As we cache this info to disk, this is for performance and
	// disk space reasons more than anything.
	// If you want it all, put ".*" in this config setting.
	// Note that if neither this or ExcludeFields is set, Hugo will return a small
	// default set.
	IncludeFields string

	// Regexp matching the Exif fields you want to exclude. This may be easier to use
	// than IncludeFields above, depending on what you want.
	ExcludeFields string

	// Hugo extracts the "photo taken" date/time into .Date by default.
	// Set this to true to turn it off.
	DisableDate bool

	// Hugo extracts the "photo taken where" (GPS latitude and longitude) into
	// .Long and .Lat. Set this to true to turn it off.
	DisableLatLong bool
}

type FileCacheConfig

type FileCacheConfig struct {
	// Max age of cache entries in this cache. Any items older than this will
	// be removed and not returned from the cache.
	// A negative value means forever, 0 means cache is disabled.
	// Hugo is lenient with what types it accepts here, but we recommend using
	// a duration string, a sequence of  decimal numbers, each with optional fraction and a unit suffix,
	// such as "300ms", "1.5h" or "2h45m".
	// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
	MaxAge time.Duration

	// The directory where files are stored.
	Dir         string
	DirCompiled string `json:"-"`

	// Will resources/_gen will get its own composite filesystem that
	// also checks any theme.
	IsResourceDir bool `json:"-"`
}

type Funcs

type Funcs struct {
	// OS env keys allowed to query in os.Getenv.
	Getenv security.Whitelist `json:"getenv"`
}

Funcs holds template funcs policies.

type HTTP

type HTTP struct {
	// URLs to allow in remote HTTP (resources.Get, getJSON, getCSV).
	URLs security.Whitelist `json:"urls"`

	// HTTP methods to allow.
	Methods security.Whitelist `json:"methods"`

	// Media types where the Content-Type in the response is used instead of resolving from the file content.
	MediaTypes security.Whitelist `json:"mediaTypes"`
}

type ImagingConfig

type ImagingConfig struct {
	// Default images quality setting (1-100). Only used for JPEG images.
	Quality int

	// Resample filter to use in resize operations.
	ResampleFilter string

	// Hint about what type of images this is.
	// Currently only used when encoding to Webp.
	// Default is "photo".
	// Valid values are "picture", "photo", "drawing", "icon", or "text".
	Hint string

	// The anchor to use in Fill. Default is "smart", i.e. Smart Crop.
	Anchor string

	// Default color used in fill operations (e.g. "fff" for white).
	BgColor string

	Exif ExifConfig
}

ImagingConfig contains default images processing configuration. This will be fetched from site (or language) config.

type ImagingConfigInternal

type ImagingConfigInternal struct {
	BgColor        color.Color
	Hint           webpoptions.EncodingPreset
	ResampleFilter gift.Resampling
	Anchor         gift.Anchor

	SourceHash string

	Imaging ImagingConfig
}

func DecodeImagingConfig

func DecodeImagingConfig(p config.Provider) (ImagingConfigInternal, error)

type Import

type Import struct {
	// Module path
	Path string

	// Ignore any config in config.toml (will still follow imports).
	IgnoreConfig bool
	// Do not follow any configured imports.
	IgnoreImports bool
	// Do not mount any folder in this import.
	NoMounts bool
	// Never vendor this import (only allowed in main project).
	NoVendor bool
	// Turn off this module.
	Disable bool
	// File mounts.
	Mounts []Mount
	// contains filtered or unexported fields
}

type LanguageConfig

type LanguageConfig struct {
	// The language name, e.g. "English".
	LanguageName string

	// The language code, e.g. "en-US".
	LanguageCode string

	// The language title. When set, this will
	// override site.Title for this language.
	Title string

	// The language direction, e.g. "ltr" or "rtl".
	LanguageDirection string

	// The language weight. When set to a non-zero value, this will
	// be the main sort criteria for the language.
	Weight int

	// Set to true to disable this language.
	Disabled bool
}

LanguageConfig holds the configuration for a single language. This is what is read from the config file.

func (LanguageConfig) Code

func (l LanguageConfig) Code() string

func (LanguageConfig) Name

func (l LanguageConfig) Name() string

type MediaTypeConfig

type MediaTypeConfig struct {
	// The file suffixes used for this media type.
	Suffixes []string
	// Delimiter used before suffix.
	Delimiter string

	Types media.Types
}

func DecodeMediaTypesConfig

func DecodeMediaTypesConfig(p config.Provider) (MediaTypeConfig, error)

type MinifyConfig

type MinifyConfig struct {
	// Whether to minify the published output (the HTML written to /public).
	MinifyOutput bool

	DisableHTML bool
	DisableCSS  bool
	DisableJS   bool
	DisableJSON bool
	DisableSVG  bool
	DisableXML  bool

	Tdewolff TdewolffConfig
}

func DecodeMinifyConfig

func DecodeMinifyConfig(p config.Provider) (conf MinifyConfig, err error)

type ModuleConfig

type ModuleConfig struct {
	// File system mounts.
	Mounts []Mount

	// Module imports.
	Imports []Import
}

func DecodeModuleConfig

func DecodeModuleConfig(cfg config.Provider) (ModuleConfig, error)

DecodeModuleConfig creates a modules Config from a given Hugo configuration.

type Mount

type Mount struct {
	// Relative path in source repo, e.g. "scss".
	Source string

	// Relative target path, e.g. "assets/bootstrap/scss".
	Target string

	// Any file in this mount will be associated with this language.
	Lang string

	// Include only files matching the given Glob patterns (string or slice).
	IncludeFiles any

	// Exclude all files matching the given Glob patterns (string or slice).
	ExcludeFiles any
}

func (Mount) Component

func (m Mount) Component() string

func (Mount) ComponentAndName

func (m Mount) ComponentAndName() (string, string)

type OutputFormatConfig

type OutputFormatConfig struct {
	// The MediaType string. This must be a configured media type.
	MediaType string
	output.Format
}

OutputFormatConfig configures a single output format.

type OutputFormatsConfig

type OutputFormatsConfig struct {
	Configs map[string]OutputFormatConfig
	output.Formats
}

func DecodeOutputFormatConfig

func DecodeOutputFormatConfig(mediaTypes media.Types, p config.Provider) (OutputFormatsConfig, error)

type RootConfig

type RootConfig struct {
	// The base URL of the site.
	// Note that the default value is empty, but Hugo requires a valid URL (e.g. "https://example.com/") to work properly.
	// <docsmeta>{"identifiers": ["URL"] }</docsmeta>
	BaseURL string

	// Whether to build content marked as draft.X
	// <docsmeta>{"identifiers": ["draft"] }</docsmeta>
	BuildDrafts bool

	// Whether to build content with expiryDate in the past.
	// <docsmeta>{"identifiers": ["expiryDate"] }</docsmeta>
	BuildExpired bool

	// Whether to build content with publishDate in the future.
	// <docsmeta>{"identifiers": ["publishDate"] }</docsmeta>
	BuildFuture bool

	// Copyright information.
	Copyright string

	// The language to apply to content without any language indicator.
	DefaultContentLanguage string

	// By default, we put the default content language in the root and the others below their language ID, e.g. /no/.
	// Set this to true to put all languages below their language ID.
	DefaultContentLanguageInSubdir bool

	// Disable creation of alias redirect pages.
	DisableAliases bool

	// Disable lower casing of path segments.
	DisablePathToLower bool

	// Disable page kinds from build.
	DisableKinds []string

	// A list of languages to disable.
	DisableLanguages []string

	// The named segments to render.
	// This needs to match the name of the segment in the segments configuration.
	RenderSegments []string

	// Disable the injection of the Hugo generator tag on the home page.
	DisableHugoGeneratorInject bool

	// Disable live reloading in server mode.
	DisableLiveReload bool

	// Enable replacement in Pages' Content of Emoji shortcodes with their equivalent Unicode characters.
	// <docsmeta>{"identifiers": ["Content", "Unicode"] }</docsmeta>
	EnableEmoji bool

	// THe main section(s) of the site.
	// If not set, Hugo will try to guess this from the content.
	MainSections []string

	// Enable robots.txt generation.
	EnableRobotsTXT bool

	// When enabled, Hugo will apply Git version information to each Page if possible, which
	// can be used to keep lastUpdated in synch and to print version information.
	// <docsmeta>{"identifiers": ["Page"] }</docsmeta>
	EnableGitInfo bool

	// Enable to track, calculate and print metrics.
	TemplateMetrics bool

	// Enable to track, print and calculate metric hints.
	TemplateMetricsHints bool

	// Enable to disable the build lock file.
	NoBuildLock bool

	// A list of log IDs to ignore.
	IgnoreLogs []string

	// A list of regexps that match paths to ignore.
	// Deprecated: Use the settings on module imports.
	IgnoreFiles []string

	// Ignore cache.
	IgnoreCache bool

	// Enable to print greppable placeholders (on the form "[i18n] TRANSLATIONID") for missing translation strings.
	EnableMissingTranslationPlaceholders bool

	// Enable to panic on warning log entries. This may make it easier to detect the source.
	PanicOnWarning bool

	// The configured environment. Default is "development" for server and "production" for build.
	Environment string

	// The default language code.
	LanguageCode string

	// Enable if the site content has CJK language (Chinese, Japanese, or Korean). This affects how Hugo counts words.
	HasCJKLanguage bool

	// The default number of pages per page when paginating.
	Paginate int

	// The path to use when creating pagination URLs, e.g. "page" in /page/2/.
	PaginatePath string

	// Whether to pluralize default list titles.
	// Note that this currently only works for English, but you can provide your own title in the content file's front matter.
	PluralizeListTitles bool

	// Whether to capitalize automatic page titles, applicable to section, taxonomy, and term pages.
	CapitalizeListTitles bool

	// Make all relative URLs absolute using the baseURL.
	// <docsmeta>{"identifiers": ["baseURL"] }</docsmeta>
	CanonifyURLs bool

	// Enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs.
	RelativeURLs bool

	// Removes non-spacing marks from composite characters in content paths.
	RemovePathAccents bool

	// Whether to track and print unused templates during the build.
	PrintUnusedTemplates bool

	// Enable to print warnings for missing translation strings.
	PrintI18nWarnings bool

	// ENable to print warnings for multiple files published to the same destination.
	PrintPathWarnings bool

	// URL to be used as a placeholder when a page reference cannot be found in ref or relref. Is used as-is.
	RefLinksNotFoundURL string

	// When using ref or relref to resolve page links and a link cannot be resolved, it will be logged with this log level.
	// Valid values are ERROR (default) or WARNING. Any ERROR will fail the build (exit -1).
	RefLinksErrorLevel string

	// This will create a menu with all the sections as menu items and all the sections’ pages as “shadow-members”.
	SectionPagesMenu string

	// The length of text in words to show in a .Summary.
	SummaryLength int

	// The site title.
	Title string

	// The theme(s) to use.
	// See Modules for more a more flexible way to load themes.
	Theme []string

	// Timeout for generating page contents, specified as a duration or in seconds.
	Timeout string

	// The time zone (or location), e.g. Europe/Oslo, used to parse front matter dates without such information and in the time function.
	TimeZone string

	// Set titleCaseStyle to specify the title style used by the title template function and the automatic section titles in Hugo.
	// It defaults to AP Stylebook for title casing, but you can also set it to Chicago or Go (every word starts with a capital letter).
	TitleCaseStyle string

	// The editor used for opening up new content.
	NewContentEditor string

	// Don't sync modification time of files for the static mounts.
	NoTimes bool

	// Don't sync modification time of files for the static mounts.
	NoChmod bool

	// Clean the destination folder before a new build.
	// This currently only handles static files.
	CleanDestinationDir bool

	// A Glob pattern of module paths to ignore in the _vendor folder.
	IgnoreVendorPaths string

	CommonDirs `mapstructure:",squash"`
}

RootConfig holds all the top-level configuration options in Hugo

func DecodeRoot

func DecodeRoot(provider config.Provider) (RootConfig, error)

type SecurityConfig

type SecurityConfig struct {
	// Restricts access to os.Exec....
	// <docsmeta>{ "newIn": "0.91.0" }</docsmeta>
	hexec.Auth `json:"exec"`

	// Restricts access to certain template funcs.
	Funcs Funcs `json:"funcs"`

	// Restricts access to resources.GetRemote, getJSON, getCSV.
	HTTP HTTP `json:"http"`

	// Allow inline shortcodes
	EnableInlineShortcodes bool `json:"enableInlineShortcodes"`
}

func DecodeSecurityConfig

func DecodeSecurityConfig(cfg config.Provider) (SecurityConfig, error)

type TdewolffConfig

type TdewolffConfig struct {
	HTML html.Minifier
	CSS  css.Minifier
	JS   js.Minifier
	JSON json.Minifier
	SVG  svg.Minifier
	XML  xml.Minifier
}

Jump to

Keyboard shortcuts

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