summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael-F-Bryan <michaelfbryan@gmail.com>2020-05-27 02:04:12 +0800
committerMichael-F-Bryan <michaelfbryan@gmail.com>2020-05-27 02:38:04 +0800
commita5086a1e585a0bde48468ef1b31460758c9f5dd7 (patch)
treea86e99df6c69a96c0a6ef4655c2ba9900a4d761b /src
parent6c4c3448e35b527253e0d0cd138a70c078514eb0 (diff)
Added a redirect map to the HTML config
Diffstat (limited to 'src')
-rw-r--r--src/config.rs17
1 files changed, 17 insertions, 0 deletions
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<String>,
+ /// The mapping from old pages to new pages/URLs to use when generating
+ /// redirects.
+ pub redirect: HashMap<PathBuf, String>,
}
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()
};