Documentation
¶
Index ¶
- func BoolPtr(v bool) *bool
- func BoolVal(p *bool, fallback bool) bool
- func NormalizeBasePath(raw string) string
- func Validate(cfg *SiteConfig, knownPlugins []string) (errs []validate.Error, warns []validate.Error)
- func ValidateVersioning(colName string, vc *VersioningConfig) error
- type AnalyticsSettings
- type BuildSettings
- type CodeblocksSettings
- type CollectionPrevNextConfig
- type CollectionSidebarConfig
- type CollectionSiteConfig
- type CollectionTOCConfig
- type ContentLintRules
- type ContentLintSettings
- type ContentSettings
- type DeployConfig
- type ExternalCheckSettings
- type FooterSettings
- type HeadSettings
- type HeadTag
- type HeaderSettings
- type HeroCTA
- type HeroCode
- type HeroImageSettings
- type HeroSettings
- type HeroStat
- type HomepageSettings
- type I18nSettings
- func (s *I18nSettings) GetDefaultLanguage() string
- func (s *I18nSettings) IsLanguageCode(seg string) bool
- func (s *I18nSettings) IsMultiLang() bool
- func (s *I18nSettings) Language(code string) (LanguageConfig, bool)
- func (s *I18nSettings) LanguageCodes() []string
- func (s *I18nSettings) ResolveLang(lang string) string
- type IconSet
- type IconSettings
- type ImageSettings
- type LanguageConfig
- type LastUpdatedStrategy
- type LinkValidationSettings
- func (s *LinkValidationSettings) EffectiveExternalOnBroken() string
- func (s *LinkValidationSettings) EffectiveOnBroken() string
- func (s *LinkValidationSettings) EffectiveOnBrokenAnchor() string
- func (s *LinkValidationSettings) EffectiveOnLocalLinks() string
- func (s *LinkValidationSettings) EffectiveOnRelativeLinks() string
- func (s *LinkValidationSettings) EffectiveOnUnverifiedInternal() string
- func (s *LinkValidationSettings) EffectiveReport() string
- type LlmsTxtSettings
- type Logo
- type MarkdownSettings
- type MarkdownTOCSettings
- type NavLink
- type PluginSettings
- type PrefetchSettings
- type ResolveOptions
- type SearchSettings
- type SecurityConfig
- type ServerSettings
- type SidebarItem
- type SidebarSettings
- type SiteConfig
- type SiteIdentity
- type SocialLink
- type TOCSettings
- type TaxonomyConfig
- type ThemeSettings
- type VersionBanner
- type VersionEntry
- type VersionRedirect
- type VersioningConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeBasePath ¶
NormalizeBasePath canonicalizes a user-supplied base path to the internal form. The canonical form always has a leading and trailing slash (e.g. "/docs/"), except the root case which is just "/".
"" -> "/" "/" -> "/" "docs" -> "/docs/" "/docs" -> "/docs/" "docs/" -> "/docs/" "/docs/" -> "/docs/" " /docs/ " -> "/docs/" "//docs//" -> "/docs/" "/a/b/" -> "/a/b/" "a//b" -> "/a/b/" "///" -> "/"
func Validate ¶
func Validate(cfg *SiteConfig, knownPlugins []string) (errs []validate.Error, warns []validate.Error)
Validate checks the merged SiteConfig for invalid values. knownPlugins is the set of valid plugin names, collected by the build layer from the actual plugin registries. If nil, plugin name validation is skipped.
func ValidateVersioning ¶
func ValidateVersioning(colName string, vc *VersioningConfig) error
ValidateVersioning checks that a versioning config is self-consistent: LastVersion must appear in Versions[].ID, and version IDs must be unique.
Types ¶
type AnalyticsSettings ¶
type BuildSettings ¶
type BuildSettings struct {
Output string `yaml:"output"`
BasePath string `yaml:"base_path"`
Clean *bool `yaml:"clean"`
Sitemap *bool `yaml:"sitemap"`
Minify *bool `yaml:"minify"`
// LastUpdated selects the strategy for page "last updated" timestamps:
// "git" — `git log -1` for the file, fall back to mtime on error
// "mtime" — filesystem modification time (default)
// "false" / "off" — disabled; no timestamp rendered
// Legacy YAML bool form is accepted: true → "mtime", false → "false" (with deprecation warning).
LastUpdated LastUpdatedStrategy `yaml:"last_updated"`
Feed *bool `yaml:"feed"`
Drafts *bool `yaml:"drafts"`
Future *bool `yaml:"future"`
Expired *bool `yaml:"expired"`
Parallel *bool `yaml:"parallel"`
Cache *bool `yaml:"cache"`
}
type CodeblocksSettings ¶
type CollectionSidebarConfig ¶
type CollectionSiteConfig ¶
type CollectionSiteConfig struct {
Enabled *bool `yaml:"enabled"`
Path string `yaml:"path"`
URLPrefix string `yaml:"url_prefix"`
Sort string `yaml:"sort"`
Layout string `yaml:"layout"`
Permalink string `yaml:"permalink"`
Paginate int `yaml:"paginate"`
Feed *bool `yaml:"feed"`
Tabs *bool `yaml:"tabs"`
Sidebar *CollectionSidebarConfig `yaml:"sidebar"`
TOC *CollectionTOCConfig `yaml:"toc"`
PrevNext *CollectionPrevNextConfig `yaml:"prev_next"`
Versioning *VersioningConfig `yaml:"versioning"`
I18nFallback string `yaml:"i18n_fallback"` // "" (inherit site), "default", or "omit"
}
type CollectionTOCConfig ¶
type ContentLintRules ¶
type ContentLintSettings ¶
type ContentLintSettings struct {
Enabled *bool `yaml:"enabled"`
Rules ContentLintRules `yaml:"rules"`
}
type ContentSettings ¶
type DeployConfig ¶
type DeployConfig struct {
Provider string `yaml:"provider"` // github, netlify, cloudflare, vercel, custom
Branch string `yaml:"branch"` // GitHub Pages branch (default: gh-pages)
SiteID string `yaml:"site_id"` // Netlify site ID
ProjectName string `yaml:"project_name"` // Cloudflare Pages project name
ProjectID string `yaml:"project_id"` // Vercel project ID
Command string `yaml:"command"` // Custom deploy command
RedirectFormat string `yaml:"redirect_format"` // html, netlify, vercel, all (default: all)
}
type ExternalCheckSettings ¶
type ExternalCheckSettings struct {
Check *bool `yaml:"check"` // default: false
Concurrency int `yaml:"concurrency"` // default: 8
Timeout string `yaml:"timeout"` // default: "10s" (parsed with time.ParseDuration)
Cache string `yaml:"cache"` // default: ".sarde/linkcache.json"
CacheTTL string `yaml:"cache_ttl"` // default: "72h"
OnBroken string `yaml:"on_broken"` // "warn" (default) | "error" | "ignore"
Ignore []string `yaml:"ignore"` // URL glob patterns to skip
Method string `yaml:"method"` // "head-then-get" (default) | "head" | "get"
}
type FooterSettings ¶
type FooterSettings struct {
}
type HeadSettings ¶
type HeaderSettings ¶
type HeroImageSettings ¶
type HeroSettings ¶
type HeroSettings struct {
Eyebrow string `yaml:"eyebrow"`
Title string `yaml:"title"`
Subtitle string `yaml:"subtitle"`
CTA *HeroCTA `yaml:"cta"`
SecondaryCTA *HeroCTA `yaml:"secondary_cta"`
Stats []HeroStat `yaml:"stats"`
Code *HeroCode `yaml:"code"`
Image *HeroImageSettings `yaml:"image"`
Background string `yaml:"background"`
}
type HomepageSettings ¶
type HomepageSettings struct {
Template string `yaml:"template"`
Hero HeroSettings `yaml:"hero"`
}
type I18nSettings ¶
type I18nSettings struct {
DefaultLanguage string `yaml:"default_language"`
Strategy string `yaml:"strategy"` // "prefix-except-default" (default)
Fallback string `yaml:"fallback"` // "default" | "omit"
Strict bool `yaml:"strict"`
Languages map[string]LanguageConfig `yaml:"languages"`
}
func (*I18nSettings) GetDefaultLanguage ¶
func (s *I18nSettings) GetDefaultLanguage() string
GetDefaultLanguage returns the configured default language code, or "en" if unset.
func (*I18nSettings) IsLanguageCode ¶
func (s *I18nSettings) IsLanguageCode(seg string) bool
IsLanguageCode reports whether seg is a registered language code.
func (*I18nSettings) IsMultiLang ¶
func (s *I18nSettings) IsMultiLang() bool
IsMultiLang returns true when the site has multiple languages configured.
func (*I18nSettings) Language ¶
func (s *I18nSettings) Language(code string) (LanguageConfig, bool)
Language returns the config for a language code, or false if not found.
func (*I18nSettings) LanguageCodes ¶
func (s *I18nSettings) LanguageCodes() []string
LanguageCodes returns all configured language codes sorted by weight then alphabetically.
func (*I18nSettings) ResolveLang ¶
func (s *I18nSettings) ResolveLang(lang string) string
ResolveLang returns the default language code when lang is empty, otherwise lang.
type IconSet ¶
IconSet names an extra Iconify JSON collection to load, by prefix, from a file path (relative to the project root).
type IconSettings ¶
type IconSettings struct {
DefaultPrefix string `yaml:"default_prefix"`
Sets []IconSet `yaml:"sets"`
SetsDir string `yaml:"sets_dir"`
LocalDir string `yaml:"local_dir"`
Attribution string `yaml:"attribution"`
// Render selects the icon output mode: "inline" (default) emits a full SVG
// per use; "sprite" emits one hidden <symbol> per unique icon per page and
// references it with <use>.
Render string `yaml:"render"`
}
IconSettings configures the SVG icon system: the default set used for bare (prefixless) names, extra Iconify sets to load, a directory of local *.svg files (resolved before any set), an attribution line for sets that require one, and the output render mode.
type ImageSettings ¶
type LanguageConfig ¶
type LastUpdatedStrategy ¶
type LastUpdatedStrategy string
LastUpdatedStrategy is a string enum with back-compat for the legacy bool form.
func (*LastUpdatedStrategy) UnmarshalYAML ¶
func (l *LastUpdatedStrategy) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML accepts strings ("git", "mtime", "false") and legacy bools (true → "mtime", false → "false") with a deprecation warning.
type LinkValidationSettings ¶
type LinkValidationSettings struct {
Enabled *bool `yaml:"enabled"`
Level string `yaml:"level"`
OnBroken string `yaml:"on_broken"` // "error" (default) | "warn" | "ignore"
OnBrokenAnchor string `yaml:"on_broken_anchor"` // "error" (default) | "warn" | "ignore"
Report string `yaml:"report"` // "pretty" (default) | "json" | "github-actions"
OnRelativeLinks string `yaml:"on_relative_links"` // "warn" (default) | "error" | "ignore"
OnLocalLinks string `yaml:"on_local_links"` // "warn" (default) | "error" | "ignore"
OnUnverifiedInternal string `yaml:"on_unverified_internal"` // "warn" (default) | "error" | "ignore" — extension-less internal links that didn't resolve in-lane
CheckAnchors *bool `yaml:"check_anchors"`
CheckImages *bool `yaml:"check_images"`
SameSitePolicy string `yaml:"same_site_policy"`
SiteRootEscapePrefix string `yaml:"site_root_escape_prefix"` // prefix (e.g. "site:") routing a link to the site root, bypassing lane logic
Exclude []string `yaml:"exclude"`
Ignore []string `yaml:"ignore"`
FailBuild *bool `yaml:"fail_build"`
External ExternalCheckSettings `yaml:"external"`
}
func (*LinkValidationSettings) EffectiveExternalOnBroken ¶
func (s *LinkValidationSettings) EffectiveExternalOnBroken() string
func (*LinkValidationSettings) EffectiveOnBroken ¶
func (s *LinkValidationSettings) EffectiveOnBroken() string
func (*LinkValidationSettings) EffectiveOnBrokenAnchor ¶
func (s *LinkValidationSettings) EffectiveOnBrokenAnchor() string
func (*LinkValidationSettings) EffectiveOnLocalLinks ¶
func (s *LinkValidationSettings) EffectiveOnLocalLinks() string
func (*LinkValidationSettings) EffectiveOnRelativeLinks ¶
func (s *LinkValidationSettings) EffectiveOnRelativeLinks() string
func (*LinkValidationSettings) EffectiveOnUnverifiedInternal ¶
func (s *LinkValidationSettings) EffectiveOnUnverifiedInternal() string
func (*LinkValidationSettings) EffectiveReport ¶
func (s *LinkValidationSettings) EffectiveReport() string
type LlmsTxtSettings ¶
type Logo ¶
Logo supports both string and object forms in YAML:
logo: "/img/logo.svg" logo: light: "/img/logo-light.svg" dark: "/img/logo-dark.svg" alt: "My Site"
type MarkdownSettings ¶
type MarkdownSettings struct {
KaTeX *bool `yaml:"katex"`
Mermaid *bool `yaml:"mermaid"`
CDN *bool `yaml:"cdn"`
Unsafe *bool `yaml:"unsafe"`
Typographer *bool `yaml:"typographer"`
GithubAlerts *bool `yaml:"github_alerts"`
TripleColonCallouts *bool `yaml:"triple_colon_callouts"`
TOC MarkdownTOCSettings `yaml:"toc"`
Codeblocks CodeblocksSettings `yaml:"codeblocks"`
}
type MarkdownTOCSettings ¶
type NavLink ¶
type NavLink struct {
}
NavLink is a labeled URL used in header and footer navigation.
type PluginSettings ¶
type PrefetchSettings ¶
type ResolveOptions ¶
type ResolveOptions struct {
ConfigPath string // path to sarde.yaml (default: "sarde.yaml")
ThemeDir string // path to active theme dir (empty = skip theme layer)
CLIFlags map[string]any // flag overrides from Cobra
EnvPrefix string // env var prefix (default: "SARDE")
Strict bool // reject unknown fields in user sarde.yaml
KnownPlugins []string // valid plugin names (collected by build layer from registries)
}
ResolveOptions provides inputs for the 5-layer config cascade.
type SearchSettings ¶
type SecurityConfig ¶
type SecurityConfig struct {
BlockedHrefSchemes []string `yaml:"blocked_href_schemes"`
}
SecurityConfig holds security-related settings for content rendering.
type ServerSettings ¶
type SidebarItem ¶
type SidebarItem struct {
Label string `yaml:"label"`
Link string `yaml:"link,omitempty"`
Collapsed *bool `yaml:"collapsed,omitempty"`
Items []SidebarItem `yaml:"items,omitempty"`
}
SidebarItem is a single entry in a manually-defined sidebar.
type SidebarSettings ¶
type SidebarSettings struct {
Collapsed *bool `yaml:"collapsed"`
Badges *bool `yaml:"badges"`
Pagination *bool `yaml:"pagination"`
AutoGenerate *bool `yaml:"auto_generate"`
Items []SidebarItem `yaml:"items"`
}
type SiteConfig ¶
type SiteConfig struct {
Site SiteIdentity `yaml:"site"`
Social []SocialLink `yaml:"social"`
Theme ThemeSettings `yaml:"theme"`
TOC TOCSettings `yaml:"toc"`
Sidebar SidebarSettings `yaml:"sidebar"`
Header HeaderSettings `yaml:"header"`
Head HeadSettings `yaml:"head"`
Build BuildSettings `yaml:"build"`
Markdown MarkdownSettings `yaml:"markdown"`
Prefetch PrefetchSettings `yaml:"prefetch"`
Images ImageSettings `yaml:"images"`
Search SearchSettings `yaml:"search"`
Icons IconSettings `yaml:"icons"`
LinkValidation LinkValidationSettings `yaml:"link_validation"`
ContentLint ContentLintSettings `yaml:"content_lint"`
Analytics AnalyticsSettings `yaml:"analytics"`
Deploy DeployConfig `yaml:"deploy"`
Redirects map[string]string `yaml:"redirects"`
Collections map[string]*CollectionSiteConfig `yaml:"collections"`
Homepage HomepageSettings `yaml:"homepage"`
Plugins PluginSettings `yaml:"plugins"`
Taxonomies map[string]TaxonomyConfig `yaml:"taxonomies"`
Server ServerSettings `yaml:"server"`
Permalinks map[string]string `yaml:"permalinks"`
I18n I18nSettings `yaml:"i18n"`
Content ContentSettings `yaml:"content"`
LlmsTxt LlmsTxtSettings `yaml:"llms_txt"`
Security SecurityConfig `yaml:"security"`
}
SiteConfig is the complete site configuration. Every field maps to a top-level key in sarde.yaml. Booleans use *bool so the merge layer can distinguish "not set" from "explicitly false".
func Defaults ¶
func Defaults() *SiteConfig
Defaults returns a fully populated SiteConfig from the embedded default YAML. This is layer 1 of the 5-layer config cascade. Panics if the embedded YAML is invalid (programmer error).
func LoadFile ¶
func LoadFile(path string) (*SiteConfig, error)
LoadFile reads a YAML config file and unmarshals it into a SiteConfig. Returns (nil, nil) if the file does not exist — missing config is not an error under the zero-config philosophy. Returns (nil, error) for invalid YAML.
func LoadFileStrict ¶
func LoadFileStrict(path string) (*SiteConfig, error)
LoadFileStrict reads a YAML config file with unknown-field detection enabled. Any field in the YAML that doesn't map to a SiteConfig struct field causes an error. Used only for the user's sarde.yaml (layer 3).
func Resolve ¶
func Resolve(opts ResolveOptions) (*SiteConfig, error)
Resolve loads and merges all config layers, returning the final SiteConfig.
Layer precedence (last wins):
- Embedded defaults (compiled into binary)
- theme.yaml (from active theme directory)
- sarde.yaml (user's project-level config)
- CLI flags
- Environment variables (SARDE_ prefix)
type SiteIdentity ¶
type SiteIdentity struct {
Title string `yaml:"title"`
Description string `yaml:"description"`
URL string `yaml:"url"`
Logo Logo `yaml:"logo"`
Favicon string `yaml:"favicon"`
Language string `yaml:"language"`
EditURL string `yaml:"edit_url"`
TitleDelimiter string `yaml:"title_delimiter"`
HeadingLinks *bool `yaml:"heading_links"`
Custom404 string `yaml:"custom_404"`
}
type SocialLink ¶
type TOCSettings ¶
type TaxonomyConfig ¶
type TaxonomyConfig struct {
Singular string `yaml:"singular"`
PaginateBy int `yaml:"paginate_by"`
UndefinedTags string `yaml:"undefined_tags"`
Render *bool `yaml:"render"`
}
TaxonomyConfig holds per-taxonomy settings. Accepts both short form ("tag") and full form ({singular: "tag", paginate_by: 20}) in YAML.
func (TaxonomyConfig) ShouldRender ¶
func (tc TaxonomyConfig) ShouldRender() bool
ShouldRender returns true if this taxonomy should generate pages. Default is true when Render is nil (not explicitly set).
func (*TaxonomyConfig) UnmarshalYAML ¶
func (tc *TaxonomyConfig) UnmarshalYAML(value *yaml.Node) error
type ThemeSettings ¶
type ThemeSettings struct {
Name string `yaml:"name"`
Preset string `yaml:"preset"`
Dark *bool `yaml:"dark"`
Overrides map[string]string `yaml:"overrides"`
DarkOverrides map[string]string `yaml:"dark_overrides"`
PrimaryColor string `yaml:"primary_color"`
AccentColor string `yaml:"accent_color"`
FontFamily string `yaml:"font_family"`
FontMono string `yaml:"font_mono"`
CodeLight string `yaml:"code_light"`
CodeDark string `yaml:"code_dark"`
}
type VersionBanner ¶
type VersionBanner string
const ( BannerNone VersionBanner = "none" BannerUnmaintained VersionBanner = "unmaintained" BannerUnreleased VersionBanner = "unreleased" )
type VersionEntry ¶
type VersionEntry struct {
ID string `yaml:"id"`
Label string `yaml:"label"`
Path string `yaml:"path"`
Banner VersionBanner `yaml:"banner"`
Redirect VersionRedirect `yaml:"redirect"`
}
VersionEntry describes one version of a versioned docs collection.
type VersionRedirect ¶
type VersionRedirect string
const ( RedirectSamePage VersionRedirect = "same-page" RedirectRoot VersionRedirect = "root" )
type VersioningConfig ¶
type VersioningConfig struct {
Enabled *bool `yaml:"enabled"`
LastVersion string `yaml:"last_version"`
PublishLatestAtVersionURL bool `yaml:"publish_latest_at_version_url"`
Fallback string `yaml:"fallback"` // "" (inherit site), "default", or "omit"
Versions []VersionEntry `yaml:"versions"`
}
VersioningConfig controls docs versioning for a collection.