Module: Coradoc::RelativePath
- Defined in:
- lib/coradoc/relative_path.rb
Overview
Pure-function module for relative-path arithmetic across output keys.
Every SSG wrapper (VitePress, Hugo, Astro) needs to compute “how many directories up do I walk to reach the site root from this output?”. The answer is the segment count of the source output_key. Everything else (template, imports) is host-system-specific; this module owns only the one piece of arithmetic that is genuinely shared.
No state. No class. No knowledge of any specific SSG.
Class Method Summary collapse
-
.from(output_key, to:) ⇒ String
Compute a relative path from an output_key to a site-root-relative target.
Class Method Details
.from(output_key, to:) ⇒ String
Compute a relative path from an output_key to a site-root-relative target.
27 28 29 30 |
# File 'lib/coradoc/relative_path.rb', line 27 def from(output_key, to:) depth = output_key.to_s.count('/') ('../' * depth) + to.to_s end |