diff --git a/src/config.rs b/src/config.rs index 4fb20be0..15c041cb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -50,6 +50,7 @@ #![deny(missing_docs)] use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use std::collections::HashMap; use std::env; use std::fs::File; use std::io::Read; @@ -514,6 +515,9 @@ pub struct HtmlConfig { /// This config item *should not be edited* by the end user. #[doc(hidden)] pub livereload_url: Option, + /// The mapping from old pages to new pages/URLs to use when generating + /// redirects. + pub redirect: HashMap, } impl Default for HtmlConfig { @@ -693,6 +697,10 @@ mod tests { editable = true editor = "ace" + [output.html.redirect] + "index.html" = "overview.html" + "nexted/page.md" = "https://rust-lang.org/" + [preprocessor.first] [preprocessor.second] @@ -731,6 +739,15 @@ mod tests { playpen: playpen_should_be, git_repository_url: Some(String::from("https://foo.com/")), git_repository_icon: Some(String::from("fa-code-fork")), + redirect: vec![ + (PathBuf::from("index.html"), String::from("overview.html")), + ( + PathBuf::from("nexted/page.md"), + String::from("https://rust-lang.org/"), + ), + ] + .into_iter() + .collect(), ..Default::default() };