diff --git a/components/library/src/content/page.rs b/components/library/src/content/page.rs index 13034158..cb69dbcf 100644 --- a/components/library/src/content/page.rs +++ b/components/library/src/content/page.rs @@ -683,6 +683,26 @@ Hello world assert_eq!(page.slug, "hello"); } + // https://github.com/getzola/zola/pull/1323#issuecomment-779401063 + #[test] + fn can_get_date_from_short_date_in_filename_respects_slugification_strategy() { + let mut config = Config::default(); + config.slugify.paths = SlugifyStrategy::Off; + let content = r#" ++++ ++++ +Hello world +"# + .to_string(); + let res = + Page::parse(Path::new("2018-10-08_ こんにちは.md"), &content, &config, &PathBuf::new()); + assert!(res.is_ok()); + let page = res.unwrap(); + + assert_eq!(page.meta.date, Some("2018-10-08".to_string())); + assert_eq!(page.slug, " こんにちは"); + } + #[test] fn can_get_date_from_full_rfc3339_date_in_filename() { let config = Config::default(); @@ -705,6 +725,30 @@ Hello world assert_eq!(page.slug, "hello"); } + // https://github.com/getzola/zola/pull/1323#issuecomment-779401063 + #[test] + fn can_get_date_from_full_rfc3339_date_in_filename_respects_slugification_strategy() { + let mut config = Config::default(); + config.slugify.paths = SlugifyStrategy::Off; + let content = r#" ++++ ++++ +Hello world +"# + .to_string(); + let res = Page::parse( + Path::new("2018-10-02T15:00:00Z- こんにちは.md"), + &content, + &config, + &PathBuf::new(), + ); + assert!(res.is_ok()); + let page = res.unwrap(); + + assert_eq!(page.meta.date, Some("2018-10-02T15:00:00Z".to_string())); + assert_eq!(page.slug, " こんにちは"); + } + #[test] fn frontmatter_date_override_filename_date() { let config = Config::default(); diff --git a/components/templates/src/global_fns/mod.rs b/components/templates/src/global_fns/mod.rs index b0c98b9f..4fe0ccaa 100644 --- a/components/templates/src/global_fns/mod.rs +++ b/components/templates/src/global_fns/mod.rs @@ -205,7 +205,11 @@ impl TeraFn for GetFileHash { let f = match open_file(&self.search_paths, &path) { Ok(f) => f, Err(e) => { - return Err(format!("File {} could not be open: {} (searched in {:?})", path, e, self.search_paths).into()); + return Err(format!( + "File {} could not be open: {} (searched in {:?})", + path, e, self.search_paths + ) + .into()); } };