Expand description
Canonical page-URL derivation shared by staging, feeds, and SEO output (spec A2/B1, plan §2 item 1.2, issue #586).
§Why this module exists
staticdatagen’s RSS generator hard-fails the whole build when a
page lacks a permalink: front-matter key (rss-gen:
“channel.link is missing”). ssg stages content through
content_stager before
staticdatagen::compile ever sees it, so ssg can guarantee a
permalink is always present by deriving one at staging time.
This module is that single derivation code path — the plan’s goal
is that canonical <link>, feed <link>, and injected
permalink: all agree because they all call
derive_page_url.
§The URL convention
Published pages use pretty directory URLs with a trailing slash,
matching the Atom feed entry convention already shipped in
src/plugins/postprocess/atom.rs ({base_url}/{rel_path}/) and
the stager’s own tags-stub permalink
(https://example.invalid/tags/):
| Relative output path | Derived URL |
|---|---|
index.html | {base_url}/ |
foo/index.html | {base_url}/foo/ |
posts/bar/index.html | {base_url}/posts/bar/ |
feed.xml (non-index) | {base_url}/feed.xml |
Windows path separators are normalised to /; percent-encoding is
left untouched (paths are already slugified upstream).
Functions§
- derive_
output_ rel_ path - Maps a content-relative markdown source path to the site-relative
output path
staticdatagen’s compiler will write for it. - derive_
page_ url - Joins a site
base_urland a page’s site-relative output path into the canonical absolute URL for that page. - derive_
permalink - Derives the canonical permalink for a content-relative markdown
source path:
derive_output_rel_pathpiped intoderive_page_url.