Skip to main content

output_to_url

Function output_to_url 

Source
pub fn output_to_url(output: &Path, output_dir: &Path) -> String
Expand description

Convert an output filesystem path (e.g. build/blog/foo/index.html) into the URL the browser tab is loaded at (/blog/foo/).

Strips the output_dir prefix and the trailing index.html so directory-style URLs match the path the browser is sitting at.

ยงExamples

use ssg::dev_server::output_to_url;
use std::path::Path;

let url = output_to_url(Path::new("build/blog/foo/index.html"), Path::new("build"));
assert_eq!(url, "/blog/foo/");