config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const DefaultPath = "tryck.config.yaml"

DefaultPath is the config file looked up when --config is not given.

View Source
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"`
	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 Defaults

func Defaults() *Config

Defaults returns the built-in 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) Apply

func (c *Config) Apply(o Overrides)

Apply layers CLI overrides on top of the loaded config.

func (*Config) Dir

func (c *Config) Dir(p string) string

Dir resolves a configured directory against the project root.

func (*Config) LayoutDirs

func (c *Config) LayoutDirs() []string

LayoutDirs lists the layout directories, lowest priority first: the theme's layouts/, then the site's layoutsDir.

func (*Config) StaticDirs

func (c *Config) StaticDirs() []string

StaticDirs lists the static directories, lowest priority first: the theme's static/, then the site's staticDir.

func (*Config) ThemeDir

func (c *Config) ThemeDir() string

ThemeDir is the theme folder, or "" when no theme is set.

func (*Config) Validate

func (c *Config) Validate() []diag.Diagnostic

Validate checks values that decode fine but make no sense.

func (*Config) WorkerCount

func (c *Config) WorkerCount() int

WorkerCount resolves build.workers, where 0 means one per CPU.

type DefaultsConfig

type DefaultsConfig struct {
	Layout     string `yaml:"layout"`
	TOC        bool   `yaml:"toc"`
	TOCDepth   [2]int `yaml:"tocDepth"` // min and max heading level
	DateFormat string `yaml:"dateFormat"`
}
type NavLink struct {
	Title string `yaml:"title"`
	URL   string `yaml:"url"`
}

NavLink is a header link.

type Overrides

type Overrides struct {
	OutputDir *string
	BaseURL   *string
	Drafts    *bool
	Workers   *int
}

Overrides holds values from CLI flags. Nil fields are not set.

type SiteConfig

type SiteConfig struct {
	Title       string `yaml:"title"`
	Description string `yaml:"description"`
	BaseURL     string `yaml:"baseUrl"`
	Language    string `yaml:"language"`
}

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
	ColorScheme string         `yaml:"colorScheme"` // auto (with a toggle), light or dark
	Nav         []NavLink      `yaml:"nav"`         // header links
	Footer      string         `yaml:"footer"`      // inline Markdown
	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.

Jump to

Keyboard shortcuts

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