Skip to main content

compile_site_with_base_url

Function compile_site_with_base_url 

Source
pub fn compile_site_with_base_url(
    build_dir: &Path,
    content_dir: &Path,
    site_dir: &Path,
    template_dir: &Path,
    base_url: Option<&str>,
) -> Result<(), SsgError>
Expand description

Compiles the static site, deriving a permalink: for every staged markdown page that declares neither permalink nor url when base_url is provided (spec A2/B1, plan §2 item 1.2, issue #586).

The derived value is crate::urls::derive_permalink applied to (base_url, content_rel_path) — i.e. the pretty directory URL of the page’s compiled output — so the injected permalink, the canonical <link>, and the feed <link> all come from one code path (crate::urls::derive_page_url). This makes rss-gen’s “channel.link is missing” hard-fail unreachable for pages without author-specified permalinks.

Passing base_url: None (or an empty string) skips the permalink derivation entirely and behaves like compile_site.

§Examples

use ssg::pipeline::compile_site_with_base_url;
use std::path::Path;

// Real call requires populated content/template trees; only the
// signature is exercised here.
let _ = compile_site_with_base_url(
    Path::new("build"), Path::new("content"),
    Path::new("site"), Path::new("templates"),
    Some("https://example.com"),
);