Documentation
¶
Overview ¶
Package config loads, defaults and validates tryck.config.yaml.
Precedence is CLI flag > config file > built-in default: Load merges the file over Defaults, then Apply layers CLI overrides on top.
Index ¶
- Constants
- type BuildConfig
- type Config
- func (c *Config) Apply(o Overrides)
- func (c *Config) Dir(p string) string
- func (c *Config) LayoutDirs() []string
- func (c *Config) PluginDirs() []string
- func (c *Config) StaticDirs() []string
- func (c *Config) ThemeDir() string
- func (c *Config) Validate() []diag.Diagnostic
- func (c *Config) WorkerCount() int
- type DefaultsConfig
- type NavLink
- type Overrides
- type SiteConfig
- type ThemeConfig
Constants ¶
const DefaultPath = "tryck.config.yaml"
DefaultPath is the config file looked up when --config is not given.
const ThemeFile = "theme.yaml"
ThemeFile is a theme folder's settings file.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildConfig ¶
type BuildConfig struct {
ContentDir string `yaml:"contentDir"`
OutputDir string `yaml:"outputDir"`
StaticDir string `yaml:"staticDir"`
LayoutsDir string `yaml:"layoutsDir"`
PluginsDir string `yaml:"pluginsDir"`
CleanOutput bool `yaml:"cleanOutput"`
Drafts bool `yaml:"drafts"`
UnsafeHTML bool `yaml:"unsafeHTML"`
Workers int `yaml:"workers"` // 0 = runtime.NumCPU()
}
type Config ¶
type Config struct {
Site SiteConfig `yaml:"site"`
Build BuildConfig `yaml:"build"`
Defaults DefaultsConfig `yaml:"defaults"`
Theme ThemeConfig `yaml:"theme"`
// Plugins maps a plugin's config name to its raw section. Each plugin
// decodes its own section.
Plugins map[string]map[string]any `yaml:"plugins"`
// Path is the config file that was loaded, or "" if none was found.
Path string `yaml:"-"`
// Root is the project root. Relative build directories resolve
// against it. It is the directory holding the config file.
Root string `yaml:"-"`
}
Config is the fully loaded site configuration.
func Load ¶
func Load(path string, required bool) (*Config, []diag.Diagnostic)
Load reads the config file at path and merges it over Defaults.
A missing file is fine unless required is set (the user passed --config explicitly). The returned Config is always usable; callers must check the diagnostics for errors.
func (*Config) LayoutDirs ¶
LayoutDirs lists the layout directories, lowest priority first: the theme's layouts/, then the site's layoutsDir.
func (*Config) PluginDirs ¶ added in v0.3.0
PluginDirs lists the script plugin directories, lowest priority first: the theme's plugins/, then the site's pluginsDir.
func (*Config) StaticDirs ¶
StaticDirs lists the static directories, lowest priority first: the theme's static/, then the site's staticDir.
func (*Config) Validate ¶
func (c *Config) Validate() []diag.Diagnostic
Validate checks values that decode fine but make no sense.
func (*Config) WorkerCount ¶
WorkerCount resolves build.workers, where 0 means one per CPU.
type DefaultsConfig ¶
type SiteConfig ¶
type ThemeConfig ¶
type ThemeConfig struct {
Path string `yaml:"path"` // theme folder with layouts/, static/ and theme.yaml
Accent string `yaml:"accent"` // CSS color for links, active nav and tabs
AccentDark string `yaml:"accentDark"` // accent in dark mode; default: accent mixed with white
Logo string `yaml:"logo"` // site path of an image shown in the header
ColorScheme string `yaml:"colorScheme"` // auto (with a toggle), light or dark
CSS []string `yaml:"css"` // extra stylesheets, linked after the theme's
Params map[string]any `yaml:"params"` // free-form values for custom themes
}
ThemeConfig selects an optional theme folder and sets the options of the built-in theme. A theme folder's theme.yaml supplies defaults for every key except path; the site config wins.