From 8d79d253f629f1c5d4f70877be8b3a300c68700a Mon Sep 17 00:00:00 2001 From: sumdonkus Date: Mon, 1 Jul 2024 19:43:41 -0600 Subject: [PATCH] Remove debugging print. Add test for generate_feeds defined in both global and default language block. Currently set to prefer the language level config. --- components/site/src/feeds.rs | 2 +- components/site/src/lib.rs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/components/site/src/feeds.rs b/components/site/src/feeds.rs index b6b728e0f..a6b497ab2 100644 --- a/components/site/src/feeds.rs +++ b/components/site/src/feeds.rs @@ -79,7 +79,7 @@ pub fn render_feeds( } else { &site.config.feed_filenames }; - println!("FF for {:?}: {:?}", lang, feed_filenames); + for feed_filename in feed_filenames { let mut context = context.clone(); diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index 44625322d..d9ef3cbbe 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -1373,4 +1373,38 @@ feed_filenames = ["rss.xml"] assert!(!std::fs::read_to_string(public_dir.join("fr").join("rss.xml")).unwrap().contains("My En Article")); assert!(std::fs::read_to_string(public_dir.join("fr").join("rss.xml")).unwrap().contains("My Fr Article")); } + + #[test] + fn can_render_feed_for_multi_language_with_language_level_feed_flag_preferred_for_default() { + let config_raw = r#" +base_url = "https://replace-this-with-your-url.com" +default_language = "en" +generate_feeds = false + +[languages.en] +title = "My English site" +generate_feeds = true + +[languages.fr] +title = "My French site" +generate_feeds = true + + "#; + let pages = vec![ + ("My En Article", "content/my-article.md", "en"), + ("My Fr Article", "content/my-article.fr.md", "fr"), + ]; + + let (tmp_dir, site) = create_site_from_config_and_pages(config_raw, &pages); + let public_dir = site.output_path; + + assert!(tmp_dir.path().exists()); + assert!(public_dir.exists()); + assert!(public_dir.join("atom.xml").exists()); + assert!(public_dir.join("fr").join("atom.xml").exists()); + assert!(std::fs::read_to_string(public_dir.join("atom.xml")).unwrap().contains("My En Article")); + assert!(!std::fs::read_to_string(public_dir.join("atom.xml")).unwrap().contains("My Fr Article")); + assert!(!std::fs::read_to_string(public_dir.join("fr").join("atom.xml")).unwrap().contains("My En Article")); + assert!(std::fs::read_to_string(public_dir.join("fr").join("atom.xml")).unwrap().contains("My Fr Article")); + } }