Hwaro::Models::Config
Inherits Reference / Object
Constants
Every top-level key load reads (scalars + load_* section names).
Used to warn on unrecognized keys instead of silently ignoring them —
a typo'd [markdonw] or titel = otherwise disables a feature with
zero feedback. Templates cannot read arbitrary raw config keys (the
site/config objects expose structured fields only), so an unknown
top-level key is always dead configuration.
Constructors
Class methods
Load and parse a config.toml into a populated Config.
Raises Hwaro::HwaroError(HWARO_E_CONFIG) directly at the source for
file-not-found and TOML parse errors so every caller (build, deploy,
doctor, tool, services) gets a classified error with exit code 3
without having to do substring matching on the exception message.
File-not-found is classified as HWARO_E_CONFIG rather than HWARO_E_IO
because a missing config.toml is a config-level user error, not an
arbitrary IO failure.
Accepts an absolute http(s)://host[:port][/path] URL or the empty
string (which means "no absolute URL is configured"). Raises
ArgumentError on anything else so callers can wrap the failure in
whichever classified HwaroError code suits their context
(HWARO_E_CONFIG for config.toml, HWARO_E_USAGE for CLI flags).
Instance methods
Path component of base_url, used to make root-relative links work when
the site is deployed under a subpath (e.g. GitHub/GitLab project pages
served at https://user.github.io/repo/). For https://x.com/repo this
returns /repo; for a domain-root deployment (https://x.com) or an
empty base_url it returns "". Trailing slashes are stripped so callers
can build base_path + page.url without producing //.
Normalize on assignment: a trailing slash makes {{ base_url }}/path
templates (and canonical/og URLs) emit //. Strip it so the build is
correct whether the trailing slash came from config.toml or --base-url
(previously only doctor --fix normalized this).
Cached base_url with trailing slash stripped (avoids repeated rstrip per page)
Get language config by code, returns nil if not found
True when built-in Sass compilation is on and relative_path is an
SCSS source — such files compile to .css instead of publishing
verbatim through the static copy. The extension must be lowercase
.scss, matching what the compiler's glob picks up — other casings
keep publishing verbatim.
Prefix a site-internal root-relative path (e.g. /posts/x/) with
base_path so generated URLs resolve under a subpath deployment.
Absolute http(s):// URLs and paths that are not root-relative are
returned unchanged; a no-op when base_path is "" (domain-root deploy).
Callers that may hold a path without a leading slash (e.g. some
page.url values) should normalize it first — this helper only
prefixes values that already start with "/".