module

Hwaro::Utils::PermalinkResolver

Constants

DATE_TOKEN_HINT = "Add a date to the page's front matter, set an explicit `path`, or remove date tokens from the pattern."
VALID_TOKENS = ["year", "month", "day", "slug", "title", "section", "filename"] of ::String

Tokens accepted inside a [permalinks] pattern value. Each token must be a whole /-separated segment (e.g. /:year/:slug/).

Instance methods

pattern?(target : String) : Bool

True when the [permalinks] target contains a :token segment, i.e. it is a Hugo-style pattern rather than a directory remap.

Source
resolve_url(relative_path : String, config : Models::Config | Nil, *, slug : String | Nil, custom_path : String | Nil, language : String | Nil, date : Time | Nil, title : String) : String

Compute the canonical site-relative URL for a content file.

Precedence: explicit path front matter (custom_path) wins outright; otherwise the language prefix for non-default languages is emitted BEFORE the pattern/remap output (/ko/2026/03/05/…), then the first matching [permalinks] rule applies (pattern expansion for leaf pages, directory remap otherwise), and the result is normalized to a leading- and trailing-slash directory URL.

A date-token pattern on a dateless page raises HWARO_E_CONTENT. Callers that can't yet know whether the page will publish (the parse fan-out runs before cascades and draft/expiry filtering) use resolve_url_lenient and defer the error to after filtering.

Source
resolve_url_lenient(relative_path : String, config : Models::Config | Nil, *, slug : String | Nil, custom_path : String | Nil, language : String | Nil, date : Time | Nil, title : String) : Tuple(String, String | Nil)

Like resolve_url, but a date-token pattern on a dateless page falls back to the default directory URL and REPORTS the problem in the second tuple slot instead of raising — so a draft or headless page the build is about to discard can't abort the whole build over a URL it never publishes.

Source
validate_pattern!(rule_key : String, target : String) : Nil

Validate every :token segment of a pattern against VALID_TOKENS. Raises a classified config error so hwaro build exits with the stable config exit code instead of silently emitting literal :tokne path segments.

Source