summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorManuel Woelker <github@manuel.woelker.org>2020-06-10 12:31:34 +0200
committerManuel Woelker <github@manuel.woelker.org>2020-06-10 12:46:23 +0200
commit06efa7a6757d00394a31ca2f4960d90e9aca3a0b (patch)
tree73bd993aa2f4d249678de2890e0ad54004ddbdd2 /src/config.rs
parentbff36e722958d28e3e8c991283250d1e3b50434f (diff)
additional changes to the 404 mechanism based on feedback:
- removed config output_404 - ensure serve overrides the site url, and hosts the correct 404 file - refactor 404 rendering into separate fn - formatting
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/config.rs b/src/config.rs
index b955e352..f6825c39 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -507,10 +507,8 @@ pub struct HtmlConfig {
/// FontAwesome icon class to use for the Git repository link.
/// Defaults to `fa-github` if `None`.
pub git_repository_icon: Option<String>,
- /// Input path for the 404 file, defaults to 404.md
+ /// Input path for the 404 file, defaults to 404.md, set to "" to disable 404 file output
pub input_404: Option<String>,
- /// Output path for 404.html file, defaults to 404.html, set to "" to disable 404 file output
- pub output_404: Option<String>,
/// Absolute url to site, used to emit correct paths for the 404 page, which might be accessed in a deeply nested directory
pub site_url: Option<String>,
/// This is used as a bit of a workaround for the `mdbook serve` command.
@@ -545,7 +543,6 @@ impl Default for HtmlConfig {
git_repository_url: None,
git_repository_icon: None,
input_404: None,
- output_404: None,
site_url: None,
livereload_url: None,
redirect: HashMap::new(),
@@ -679,6 +676,7 @@ impl<'de, T> Updateable<'de> for T where T: Serialize + Deserialize<'de> {}
#[cfg(test)]
mod tests {
use super::*;
+ use crate::utils::fs::get_404_output_file;
const COMPLEX_CONFIG: &str = r#"
[book]
@@ -1024,7 +1022,10 @@ mod tests {
let got = Config::from_str(src).unwrap();
let html_config = got.html_config().unwrap();
assert_eq!(html_config.input_404, None);
- assert_eq!(html_config.output_404, None);
+ assert_eq!(
+ &get_404_output_file(html_config.input_404.as_deref()),
+ "404.html"
+ );
}
#[test]
@@ -1038,6 +1039,9 @@ mod tests {
let got = Config::from_str(src).unwrap();
let html_config = got.html_config().unwrap();
assert_eq!(html_config.input_404, Some("missing.md".to_string()));
- assert_eq!(html_config.output_404, Some("missing.html".to_string()));
+ assert_eq!(
+ &get_404_output_file(html_config.input_404.as_deref()),
+ "missing.html"
+ );
}
}