diff --git a/CHANGELOG.md b/CHANGELOG.md index 696e94ae..8d4cbc9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ also specify classes on headers now - Make `ignored_content` work with nested paths and directories - `zola serve/build` can now run from anywhere in a zola directory - Add XML support to `load_data` +- `skip_prefixes` is now checked before parsing external link URLs ## 0.15.3 (2022-01-23) diff --git a/components/content/src/lib.rs b/components/content/src/lib.rs index 661b365c..6789c43a 100644 --- a/components/content/src/lib.rs +++ b/components/content/src/lib.rs @@ -19,6 +19,3 @@ pub use pagination::Paginator; pub use section::Section; pub use taxonomies::{Taxonomy, TaxonomyItem}; pub use types::*; - -// TODO -// 3. add more tests diff --git a/components/utils/src/site.rs b/components/utils/src/site.rs index 26d4cad4..d09e8833 100644 --- a/components/utils/src/site.rs +++ b/components/utils/src/site.rs @@ -1,19 +1,9 @@ use libs::percent_encoding::percent_decode; -use libs::unicode_segmentation::UnicodeSegmentation; use std::collections::HashMap; use std::hash::BuildHasher; use errors::{anyhow, Result}; -// TODO: move to content -/// Get word count and estimated reading time -pub fn get_reading_analytics(content: &str) -> (usize, usize) { - let word_count: usize = content.unicode_words().count(); - - // https://help.medium.com/hc/en-us/articles/214991667-Read-time - // 275 seems a bit too high though - (word_count, ((word_count + 199) / 200)) -} /// Result of a successful resolution of an internal link. #[derive(Debug, PartialEq, Clone)] @@ -58,7 +48,7 @@ pub fn resolve_internal_link( mod tests { use std::collections::HashMap; - use super::{get_reading_analytics, resolve_internal_link}; + use super::{resolve_internal_link}; #[test] fn can_resolve_valid_internal_link() { @@ -104,29 +94,4 @@ mod tests { let res = resolve_internal_link("@/pages/about.md#hello", &HashMap::new()); assert!(res.is_err()); } - - #[test] - fn reading_analytics_empty_text() { - let (word_count, reading_time) = get_reading_analytics(" "); - assert_eq!(word_count, 0); - assert_eq!(reading_time, 0); - } - - #[test] - fn reading_analytics_short_text() { - let (word_count, reading_time) = get_reading_analytics("Hello World"); - assert_eq!(word_count, 2); - assert_eq!(reading_time, 1); - } - - #[test] - fn reading_analytics_long_text() { - let mut content = String::new(); - for _ in 0..1000 { - content.push_str(" Hello world"); - } - let (word_count, reading_time) = get_reading_analytics(&content); - assert_eq!(word_count, 2000); - assert_eq!(reading_time, 10); - } }