diff --git a/CHANGELOG.md b/CHANGELOG.md index cfcfd68e..5b75a58b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ - Newlines are now required after the closing `+++` of front-matter - i18n rework: languages now have their sections in `config.toml` to set up all their options 1. taxonomies don't have a `lang` anymore in the config, you need to declare them in their respective language section - 2. + 2. the `config` variable in templates has been changed and is now a stripped down language aware version of the previous `config` + object ### Other diff --git a/components/config/src/config/mod.rs b/components/config/src/config/mod.rs index 8fba9079..cbc6511f 100644 --- a/components/config/src/config/mod.rs +++ b/components/config/src/config/mod.rs @@ -20,14 +20,14 @@ use utils::fs::read_file; // We want a default base url for tests static DEFAULT_BASE_URL: &str = "http://a-website.com"; -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum Mode { Build, Serve, Check, } -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Deserialize)] #[serde(default)] pub struct Config { /// Base URL of the site, the only required config argument @@ -87,20 +87,30 @@ pub struct Config { pub output_dir: String, pub link_checker: link_checker::LinkChecker, - /// The setup for which slugification strategies to use for paths, taxonomies and anchors pub slugify: slugify::Slugify, - /// The search config, telling what to include in the search index pub search: search::Search, - /// The config for the Markdown rendering: syntax highlighting and everything pub markdown: markup::Markdown, - /// All user params set in [extra] in the config pub extra: HashMap, } +#[derive(Serialize)] +pub struct SerializedConfig<'a> { + base_url: &'a str, + mode: Mode, + title: &'a Option, + description: &'a Option, + languages: HashMap<&'a String, &'a languages::LanguageOptions>, + translations: &'a HashMap, + generate_feed: bool, + taxonomies: &'a [taxonomies::Taxonomy], + build_search_index: bool, + extra: &'a HashMap, +} + impl Config { /// Parses a string containing TOML to our Config struct /// Any extra parameter will end up in the extra field @@ -115,7 +125,10 @@ impl Config { } if !THEME_SET.themes.contains_key(&config.markdown.highlight_theme) { - bail!("Highlight theme {} defined in config does not exist.", config.markdown.highlight_theme); + bail!( + "Highlight theme {} defined in config does not exist.", + config.markdown.highlight_theme + ); } languages::validate_code(&config.default_language)?; @@ -123,21 +136,7 @@ impl Config { languages::validate_code(&code)?; } - // We automatically insert a language option for the default language *if* it isn't present - // TODO: what to do if there is like an empty dict for the lang? merge it or use the language - // TODO: as source of truth? - if !config.languages.contains_key(&config.default_language) { - config.languages.insert( - config.default_language.clone(), - languages::LanguageOptions { - title: config.title.clone(), - description: config.title.clone(), - generate_feed: config.generate_feed, - build_search_index: config.build_search_index, - taxonomies: config.taxonomies.clone(), - }, - ); - } + config.add_default_language(); if !config.ignored_content.is_empty() { // Convert the file glob strings into a compiled glob set matcher. We want to do this once, @@ -192,6 +191,25 @@ impl Config { } } + /// Adds the default language to the list of languages if not present + fn add_default_language(&mut self) { + // We automatically insert a language option for the default language *if* it isn't present + // TODO: what to do if there is like an empty dict for the lang? merge it or use the language + // TODO: as source of truth? + if !self.languages.contains_key(&self.default_language) { + self.languages.insert( + self.default_language.clone(), + languages::LanguageOptions { + title: self.title.clone(), + description: self.title.clone(), + generate_feed: self.generate_feed, + build_search_index: self.build_search_index, + taxonomies: self.taxonomies.clone(), + }, + ); + } + } + /// Merges the extra data from the theme with the config extra data fn add_theme_extra(&mut self, theme: &Theme) -> Result<()> { for (key, val) in &theme.extra { @@ -259,6 +277,23 @@ impl Config { }) .map(|term| term.to_string()) } + + pub fn serialize(&self, lang: &str) -> SerializedConfig { + let options = &self.languages[lang]; + + SerializedConfig { + base_url: &self.base_url, + mode: self.mode, + title: &options.title, + description: &options.description, + languages: self.languages.iter().filter(|(k, _)| k.as_str() != lang).collect(), + translations: &self.translations, + generate_feed: options.generate_feed, + taxonomies: &options.taxonomies, + build_search_index: self.build_search_index, + extra: &self.extra, + } + } } // merge TOML data that can be a table, or anything else @@ -291,7 +326,7 @@ pub fn merge(into: &mut Toml, from: &Toml) -> Result<()> { impl Default for Config { fn default() -> Config { - Config { + let mut config = Config { base_url: DEFAULT_BASE_URL.to_string(), title: None, description: None, @@ -316,7 +351,9 @@ impl Default for Config { search: search::Search::default(), markdown: markup::Markdown::default(), extra: HashMap::new(), - } + }; + config.add_default_language(); + config } } diff --git a/components/config/src/lib.rs b/components/config/src/lib.rs index 130b88bf..3b5ff501 100644 --- a/components/config/src/lib.rs +++ b/components/config/src/lib.rs @@ -2,7 +2,6 @@ mod config; pub mod highlighting; mod theme; - pub use crate::config::{ languages::LanguageOptions, link_checker::LinkChecker, slugify::Slugify, taxonomies::Taxonomy, Config, diff --git a/components/library/src/content/page.rs b/components/library/src/content/page.rs index b0e8df85..6d8ae36d 100644 --- a/components/library/src/content/page.rs +++ b/components/library/src/content/page.rs @@ -249,8 +249,14 @@ impl Page { config: &Config, anchor_insert: InsertAnchor, ) -> Result<()> { - let mut context = - RenderContext::new(tera, config, &self.permalink, permalinks, anchor_insert); + let mut context = RenderContext::new( + tera, + config, + &self.lang, + &self.permalink, + permalinks, + anchor_insert, + ); context.tera_context.insert("page", &SerializingPage::from_page_basic(self, None)); @@ -275,7 +281,7 @@ impl Page { }; let mut context = TeraContext::new(); - context.insert("config", config); + context.insert("config", &config.serialize(&self.lang)); context.insert("current_url", &self.permalink); context.insert("current_path", &self.path); context.insert("page", &self.to_serialized(library)); diff --git a/components/library/src/content/section.rs b/components/library/src/content/section.rs index 00c9024f..1b284cca 100644 --- a/components/library/src/content/section.rs +++ b/components/library/src/content/section.rs @@ -172,6 +172,7 @@ impl Section { let mut context = RenderContext::new( tera, config, + &self.lang, &self.permalink, permalinks, self.meta.insert_anchor_links, @@ -195,7 +196,7 @@ impl Section { let tpl_name = self.get_template_name(); let mut context = TeraContext::new(); - context.insert("config", config); + context.insert("config", &config.serialize(&self.lang)); context.insert("current_url", &self.permalink); context.insert("current_path", &self.path); context.insert("section", &self.to_serialized(library)); diff --git a/components/library/src/pagination/mod.rs b/components/library/src/pagination/mod.rs index 1287d149..e1bf525d 100644 --- a/components/library/src/pagination/mod.rs +++ b/components/library/src/pagination/mod.rs @@ -223,17 +223,18 @@ impl<'a> Paginator<'a> { library: &Library, ) -> Result { let mut context = Context::new(); - context.insert("config", &config); match self.root { PaginationRoot::Section(s) => { context .insert("section", &SerializingSection::from_section_basic(s, Some(library))); context.insert("lang", &s.lang); + context.insert("config", &config.serialize(&s.lang)); } PaginationRoot::Taxonomy(t, item) => { context.insert("taxonomy", &t.kind); context.insert("term", &item.serialize(library)); context.insert("lang", &t.lang); + context.insert("config", &config.serialize(&t.lang)); } }; context.insert("current_url", &pager.permalink); diff --git a/components/library/src/taxonomies/mod.rs b/components/library/src/taxonomies/mod.rs index 6b5eb828..3f34e934 100644 --- a/components/library/src/taxonomies/mod.rs +++ b/components/library/src/taxonomies/mod.rs @@ -178,7 +178,7 @@ impl Taxonomy { library: &Library, ) -> Result { let mut context = Context::new(); - context.insert("config", config); + context.insert("config", &config.serialize(&self.lang)); context.insert("lang", &self.lang); context.insert("term", &SerializedTaxonomyItem::from_item(item, library)); context.insert("taxonomy", &self.kind); @@ -201,7 +201,7 @@ impl Taxonomy { library: &Library, ) -> Result { let mut context = Context::new(); - context.insert("config", config); + context.insert("config", &config.serialize(&self.lang)); let terms: Vec = self.items.iter().map(|i| SerializedTaxonomyItem::from_item(i, library)).collect(); context.insert("terms", &terms); diff --git a/components/rendering/src/context.rs b/components/rendering/src/context.rs index 30249d36..aebdb431 100644 --- a/components/rendering/src/context.rs +++ b/components/rendering/src/context.rs @@ -20,12 +20,13 @@ impl<'a> RenderContext<'a> { pub fn new( tera: &'a Tera, config: &'a Config, + lang: &'a str, current_page_permalink: &'a str, permalinks: &'a HashMap, insert_anchor: InsertAnchor, ) -> RenderContext<'a> { let mut tera_context = Context::new(); - tera_context.insert("config", config); + tera_context.insert("config", &config.serialize(lang)); Self { tera: Cow::Borrowed(tera), tera_context, diff --git a/components/rendering/src/shortcode.rs b/components/rendering/src/shortcode.rs index aece80ee..298b9a4e 100644 --- a/components/rendering/src/shortcode.rs +++ b/components/rendering/src/shortcode.rs @@ -270,7 +270,14 @@ mod tests { fn render_shortcodes(code: &str, tera: &Tera) -> String { let config = Config::default(); let permalinks = HashMap::new(); - let context = RenderContext::new(&tera, &config, "", &permalinks, InsertAnchor::None); + let context = RenderContext::new( + &tera, + &config, + &config.default_language, + "", + &permalinks, + InsertAnchor::None, + ); super::render_shortcodes(code, &context).unwrap() } diff --git a/components/rendering/tests/codeblock_hl_lines.rs b/components/rendering/tests/codeblock_hl_lines.rs index 6f0eb7e4..23db55be 100644 --- a/components/rendering/tests/codeblock_hl_lines.rs +++ b/components/rendering/tests/codeblock_hl_lines.rs @@ -38,7 +38,14 @@ fn hl_lines_simple() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" ```hl_lines=2 @@ -67,7 +74,14 @@ fn hl_lines_in_middle() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" ```hl_lines=2-3 @@ -96,7 +110,14 @@ fn hl_lines_all() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" ```hl_lines=1-4 @@ -123,7 +144,14 @@ fn hl_lines_start_from_one() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" ```hl_lines=1-3 @@ -151,7 +179,14 @@ fn hl_lines_start_from_zero() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" ```hl_lines=0-3 @@ -179,7 +214,14 @@ fn hl_lines_end() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" ```hl_lines=3-4 @@ -207,7 +249,14 @@ fn hl_lines_end_out_of_bounds() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" ```hl_lines=3-4294967295 @@ -235,7 +284,14 @@ fn hl_lines_overlap() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" ```hl_lines=2-3 1-2 @@ -262,7 +318,14 @@ fn hl_lines_multiple() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" ```hl_lines=2-3,hl_lines=1-2 @@ -290,7 +353,14 @@ fn hl_lines_extra_spaces() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" ``` hl_lines = 2 - 3 1 - 2 @@ -318,7 +388,14 @@ fn hl_lines_int_and_range() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" ```hl_lines=1 3-4 @@ -347,7 +424,14 @@ fn hl_lines_single_line_range() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" ```hl_lines=2-2 @@ -376,7 +460,14 @@ fn hl_lines_reverse_range() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" ```hl_lines=3-2 diff --git a/components/rendering/tests/markdown.rs b/components/rendering/tests/markdown.rs index 468ff8ac..0c6296c0 100644 --- a/components/rendering/tests/markdown.rs +++ b/components/rendering/tests/markdown.rs @@ -13,7 +13,14 @@ fn can_do_render_content_simple() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("hello", &context).unwrap(); assert_eq!(res.body, "

hello

\n"); } @@ -24,7 +31,14 @@ fn doesnt_highlight_code_block_with_highlighting_off() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = false; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("```\n$ gutenberg server\n```", &context).unwrap(); assert_eq!(res.body, "
$ gutenberg server\n
\n"); } @@ -35,7 +49,14 @@ fn can_highlight_code_block_no_lang() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("```\n$ gutenberg server\n$ ping\n```", &context).unwrap(); assert_eq!( res.body, @@ -49,7 +70,14 @@ fn can_highlight_code_block_with_lang() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("```python\nlist.append(1)\n```", &context).unwrap(); assert_eq!( res.body, @@ -63,7 +91,14 @@ fn can_higlight_code_block_with_unknown_lang() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = true; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("```yolo\nlist.append(1)\n```", &context).unwrap(); // defaults to plain text assert_eq!( @@ -76,7 +111,14 @@ fn can_higlight_code_block_with_unknown_lang() { fn can_render_shortcode() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" Hello @@ -96,7 +138,14 @@ Hello fn can_render_shortcode_with_markdown_char_in_args_name() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let input = vec!["name", "na_me", "n_a_me", "n1"]; for i in input { let res = @@ -109,7 +158,14 @@ fn can_render_shortcode_with_markdown_char_in_args_name() { fn can_render_shortcode_with_markdown_char_in_args_value() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let input = vec![ "ub36ffWAqgQ-hey", "ub36ffWAqgQ_hey", @@ -139,7 +195,14 @@ fn can_render_body_shortcode_with_markdown_char_in_name() { "
{{ body }} - {{ author}}
", ) .unwrap(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content(&format!("{{% {}(author=\"Bob\") %}}\nhey\n{{% end %}}", i), &context) @@ -170,7 +233,14 @@ Here is another paragraph. tera.add_raw_template("shortcodes/figure.html", shortcode).unwrap(); let config = Config::default(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content(markdown_string, &context).unwrap(); @@ -203,7 +273,14 @@ Here is another paragraph. tera.add_raw_template("shortcodes/figure.html", shortcode).unwrap(); let config = Config::default(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content(markdown_string, &context).unwrap(); @@ -214,7 +291,14 @@ Here is another paragraph. fn can_render_several_shortcode_in_row() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" Hello @@ -249,7 +333,14 @@ fn doesnt_render_ignored_shortcodes() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.highlight_code = false; - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content(r#"```{{/* youtube(id="w7Ft2ymGmfc") */}}```"#, &context).unwrap(); assert_eq!(res.body, "

{{ youtube(id="w7Ft2ymGmfc") }}

\n"); } @@ -265,7 +356,14 @@ fn can_render_shortcode_with_body() { .unwrap(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" @@ -285,7 +383,14 @@ fn errors_rendering_unknown_shortcode() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("{{ hello(flash=true) }}", &context); assert!(res.is_err()); } @@ -296,7 +401,14 @@ fn can_make_valid_relative_link() { permalinks.insert("pages/about.md".to_string(), "https://vincent.is/about".to_string()); let tera_ctx = Tera::default(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks, + InsertAnchor::None, + ); let res = render_content( r#"[rel link](@/pages/about.md), [abs link](https://vincent.is/about)"#, &context, @@ -314,7 +426,14 @@ fn can_make_relative_links_with_anchors() { permalinks.insert("pages/about.md".to_string(), "https://vincent.is/about".to_string()); let tera_ctx = Tera::default(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks, + InsertAnchor::None, + ); let res = render_content(r#"[rel link](@/pages/about.md#cv)"#, &context).unwrap(); assert!(res.body.contains(r#"

rel link

"#)); @@ -325,7 +444,14 @@ fn errors_relative_link_inexistant() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("[rel link](@/pages/about.md)", &context); assert!(res.is_err()); } @@ -335,7 +461,14 @@ fn can_add_id_to_headings() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content(r#"# Hello"#, &context).unwrap(); assert_eq!(res.body, "

Hello

\n"); } @@ -345,7 +478,14 @@ fn can_add_id_to_headings_same_slug() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("# Hello\n# Hello", &context).unwrap(); assert_eq!(res.body, "

Hello

\n

Hello

\n"); } @@ -356,7 +496,14 @@ fn can_add_non_slug_id_to_headings() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.slugify.anchors = SlugifyStrategy::Safe; - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content(r#"# L'écologie et vous"#, &context).unwrap(); assert_eq!(res.body, "

L'écologie et vous

\n"); } @@ -366,7 +513,14 @@ fn can_handle_manual_ids_on_headings() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); // Tested things: manual IDs; whitespace flexibility; that automatic IDs avoid collision with // manual IDs; that duplicates are in fact permitted among manual IDs; that any non-plain-text // in the middle of `{#…}` will disrupt it from being acknowledged as a manual ID (that last @@ -403,7 +557,14 @@ fn blank_headings() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("# \n#\n# {#hmm} \n# {#}", &context).unwrap(); assert_eq!( res.body, @@ -415,7 +576,14 @@ fn blank_headings() { fn can_insert_anchor_left() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::Left); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::Left, + ); let res = render_content("# Hello", &context).unwrap(); assert_eq!( res.body, @@ -427,7 +595,14 @@ fn can_insert_anchor_left() { fn can_insert_anchor_right() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::Right); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::Right, + ); let res = render_content("# Hello", &context).unwrap(); assert_eq!( res.body, @@ -439,7 +614,14 @@ fn can_insert_anchor_right() { fn can_insert_anchor_for_multi_heading() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::Right); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::Right, + ); let res = render_content("# Hello\n# World", &context).unwrap(); assert_eq!( res.body, @@ -453,7 +635,14 @@ fn can_insert_anchor_for_multi_heading() { fn can_insert_anchor_with_exclamation_mark() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::Left); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::Left, + ); let res = render_content("# Hello!", &context).unwrap(); assert_eq!( res.body, @@ -466,7 +655,14 @@ fn can_insert_anchor_with_exclamation_mark() { fn can_insert_anchor_with_link() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::Left); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::Left, + ); let res = render_content("## [Rust](https://rust-lang.org)", &context).unwrap(); assert_eq!( res.body, @@ -478,7 +674,14 @@ fn can_insert_anchor_with_link() { fn can_insert_anchor_with_other_special_chars() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::Left); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::Left, + ); let res = render_content("# Hello*_()", &context).unwrap(); assert_eq!( res.body, @@ -493,6 +696,7 @@ fn can_make_toc() { let context = RenderContext::new( &ZOLA_TERA, &config, + &config.default_language, "https://mysite.com/something", &permalinks_ctx, InsertAnchor::Left, @@ -525,6 +729,7 @@ fn can_ignore_tags_in_toc() { let context = RenderContext::new( &ZOLA_TERA, &config, + &config.default_language, "https://mysite.com/something", &permalinks_ctx, InsertAnchor::Left, @@ -558,7 +763,14 @@ fn can_ignore_tags_in_toc() { fn can_understand_backtick_in_titles() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("# `Hello`", &context).unwrap(); assert_eq!(res.body, "

Hello

\n"); } @@ -567,7 +779,14 @@ fn can_understand_backtick_in_titles() { fn can_understand_backtick_in_paragraphs() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("Hello `world`", &context).unwrap(); assert_eq!(res.body, "

Hello world

\n"); } @@ -577,7 +796,14 @@ fn can_understand_backtick_in_paragraphs() { fn can_understand_links_in_heading() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("# [Rust](https://rust-lang.org)", &context).unwrap(); assert_eq!(res.body, "

Rust

\n"); } @@ -586,7 +812,14 @@ fn can_understand_links_in_heading() { fn can_understand_link_with_title_in_heading() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("# [Rust](https://rust-lang.org \"Rust homepage\")", &context).unwrap(); assert_eq!( @@ -599,7 +832,14 @@ fn can_understand_link_with_title_in_heading() { fn can_understand_emphasis_in_heading() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("# *Emphasis* text", &context).unwrap(); assert_eq!(res.body, "

Emphasis text

\n"); } @@ -608,7 +848,14 @@ fn can_understand_emphasis_in_heading() { fn can_understand_strong_in_heading() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("# **Strong** text", &context).unwrap(); assert_eq!(res.body, "

Strong text

\n"); } @@ -617,7 +864,14 @@ fn can_understand_strong_in_heading() { fn can_understand_code_in_heading() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("# `Code` text", &context).unwrap(); assert_eq!(res.body, "

Code text

\n"); } @@ -627,7 +881,14 @@ fn can_understand_code_in_heading() { fn can_understand_footnote_in_heading() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("# text [^1] there\n[^1]: footnote", &context).unwrap(); assert_eq!( res.body, @@ -645,7 +906,14 @@ fn can_make_valid_relative_link_in_heading() { permalinks.insert("pages/about.md".to_string(), "https://vincent.is/about/".to_string()); let tera_ctx = Tera::default(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks, + InsertAnchor::None, + ); let res = render_content(r#" # [rel link](@/pages/about.md)"#, &context).unwrap(); assert_eq!( @@ -661,6 +929,7 @@ fn can_make_permalinks_with_colocated_assets_for_link() { let context = RenderContext::new( &ZOLA_TERA, &config, + &config.default_language, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None, @@ -676,6 +945,7 @@ fn can_make_permalinks_with_colocated_assets_for_image() { let context = RenderContext::new( &ZOLA_TERA, &config, + &config.default_language, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None, @@ -694,6 +964,7 @@ fn markdown_doesnt_wrap_html_in_paragraph() { let context = RenderContext::new( &ZOLA_TERA, &config, + &config.default_language, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None, @@ -726,6 +997,7 @@ fn correctly_captures_external_links() { let context = RenderContext::new( &ZOLA_TERA, &config, + &config.default_language, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None, @@ -748,7 +1020,14 @@ fn can_handle_summaries() { let tera_ctx = Tera::default(); let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera_ctx, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content( r#" Hello [My site][world] @@ -796,7 +1075,14 @@ fn doesnt_try_to_highlight_content_from_shortcode() { tera.add_raw_template("shortcodes/figure.html", shortcode).unwrap(); let config = Config::default(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content(markdown_string, &context).unwrap(); assert_eq!(res.body, expected); @@ -818,7 +1104,14 @@ fn can_emit_newlines_and_whitespace_with_shortcode() { tera.add_raw_template(&format!("shortcodes/{}.html", "preformatted"), shortcode).unwrap(); let config = Config::default(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content(markdown_string, &context).unwrap(); assert_eq!(res.body, expected); @@ -846,7 +1139,7 @@ fn can_emit_newlines_and_whitespace_with_shortcode() { // // tera.add_raw_template(&format!("shortcodes/{}.html", "alert"), shortcode).unwrap(); // let config = Config::default(); -// let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); +// let context = RenderContext::new(&tera, &config, &config.default_language, "", &permalinks_ctx, InsertAnchor::None); // // let res = render_content(markdown_string, &context).unwrap(); // assert_eq!(res.body, expected); @@ -870,6 +1163,7 @@ fn leaves_custom_url_scheme_untouched() { let context = RenderContext::new( &tera_ctx, &config, + &config.default_language, "https://vincent.is/", &permalinks_ctx, InsertAnchor::None, @@ -896,6 +1190,7 @@ fn stops_with_an_error_on_an_empty_link() { let context = RenderContext::new( &tera_ctx, &config, + &config.default_language, "https://vincent.is/", &permalinks_ctx, InsertAnchor::None, @@ -943,7 +1238,14 @@ Bla bla"#; tera.add_raw_template("shortcodes/quote.md", shortcode).unwrap(); let config = Config::default(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content(markdown_string, &context).unwrap(); @@ -973,7 +1275,14 @@ fn can_render_shortcode_body_with_no_invalid_escaping() { tera.add_raw_template("shortcodes/resize_image.html", shortcode).unwrap(); let config = Config::default(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content(markdown_string, &context).unwrap(); assert_eq!(res.body, expected); @@ -1002,7 +1311,14 @@ fn can_render_commented_out_shortcodes_fine() { tera.add_raw_template("shortcodes/resize_image.html", shortcode).unwrap(); let config = Config::default(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content(markdown_string, &context).unwrap(); assert_eq!(res.body, expected); @@ -1034,7 +1350,14 @@ Again more text"#; tera.add_raw_template("shortcodes/quote.md", shortcode).unwrap(); let config = Config::default(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content(markdown_string, &context).unwrap(); assert_eq!(res.body, expected); @@ -1045,7 +1368,14 @@ fn can_render_emoji_alias() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.render_emoji = true; - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("Hello, World! :smile:", &context).unwrap(); assert_eq!(res.body, "

Hello, World! 😄

\n"); } @@ -1054,7 +1384,14 @@ fn can_render_emoji_alias() { fn emoji_aliases_are_ignored_when_disabled_in_config() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("Hello, World! :smile:", &context).unwrap(); assert_eq!(res.body, "

Hello, World! :smile:

\n"); } @@ -1083,7 +1420,14 @@ fn invocation_count_increments_in_shortcode() { tera.add_raw_template("shortcodes/a.html", shortcode_template_a).unwrap(); tera.add_raw_template("shortcodes/b.html", shortcode_template_b).unwrap(); let config = Config::default(); - let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &tera, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content(markdown_string, &context).unwrap(); assert_eq!(res.body, expected); @@ -1093,7 +1437,14 @@ fn invocation_count_increments_in_shortcode() { fn basic_external_links_unchanged() { let permalinks_ctx = HashMap::new(); let config = Config::default(); - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("", &context).unwrap(); assert_eq!(res.body, "

https://google.com

\n"); } @@ -1103,7 +1454,14 @@ fn can_set_target_blank_for_external_link() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.external_links_target_blank = true; - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("", &context).unwrap(); assert_eq!(res.body, "

https://google.com

\n"); } @@ -1113,7 +1471,14 @@ fn can_set_nofollow_for_external_link() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.external_links_no_follow = true; - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); // Testing href escaping while we're there let res = render_content("", &context).unwrap(); assert_eq!( @@ -1127,7 +1492,14 @@ fn can_set_noreferrer_for_external_link() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.external_links_no_referrer = true; - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("", &context).unwrap(); assert_eq!( res.body, @@ -1142,7 +1514,14 @@ fn can_set_all_options_for_external_link() { config.markdown.external_links_target_blank = true; config.markdown.external_links_no_follow = true; config.markdown.external_links_no_referrer = true; - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content("", &context).unwrap(); assert_eq!(res.body, "

https://google.com

\n"); } @@ -1152,7 +1531,14 @@ fn can_use_smart_punctuation() { let permalinks_ctx = HashMap::new(); let mut config = Config::default(); config.markdown.smart_punctuation = true; - let context = RenderContext::new(&ZOLA_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); + let context = RenderContext::new( + &ZOLA_TERA, + &config, + &config.default_language, + "", + &permalinks_ctx, + InsertAnchor::None, + ); let res = render_content(r#"This -- is "it"..."#, &context).unwrap(); assert_eq!(res.body, "

This – is “it”…

\n"); } diff --git a/components/site/src/feed.rs b/components/site/src/feed.rs index 13c45cdb..f999656a 100644 --- a/components/site/src/feed.rs +++ b/components/site/src/feed.rs @@ -59,7 +59,7 @@ pub fn render_feed( pages.iter().take(num_entries).map(|x| x.to_serialized_basic(&library)).collect::>(); context.insert("pages", &p); - context.insert("config", &site.config); + context.insert("config", &site.config.serialize(lang)); context.insert("lang", lang); let feed_filename = &site.config.feed_filename; diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index 42ebd687..a69bf39b 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -760,7 +760,7 @@ impl Site { pub fn render_404(&self) -> Result<()> { ensure_directory_exists(&self.output_path)?; let mut context = Context::new(); - context.insert("config", &self.config); + context.insert("config", &self.config.serialize(&self.config.default_language)); context.insert("lang", &self.config.default_language); let output = render_template("404.html", &self.tera, context, &self.config.theme)?; let content = self.inject_livereload(output); @@ -772,7 +772,7 @@ impl Site { pub fn render_robots(&self) -> Result<()> { ensure_directory_exists(&self.output_path)?; let mut context = Context::new(); - context.insert("config", &self.config); + context.insert("config", &self.config.serialize(&self.config.default_language)); let content = render_template("robots.txt", &self.tera, context, &self.config.theme)?; self.write_content(&[], "robots.txt", content, false)?; Ok(()) diff --git a/src/cmd/init.rs b/src/cmd/init.rs index 5ce05f17..1bc76922 100644 --- a/src/cmd/init.rs +++ b/src/cmd/init.rs @@ -256,9 +256,9 @@ mod tests { } create_dir(&dir).expect("Could not create test directory"); if cfg!(target_os = "windows") { - let stripped_path = strip_unc(&canonicalize(Path::new(&dir)).unwrap()); - assert!(same_file::is_same_file(Path::new(&stripped_path),&dir).unwrap()); - assert!(!stripped_path.starts_with(LOCAL_UNC),"The path was not stripped."); + let stripped_path = strip_unc(&canonicalize(Path::new(&dir)).unwrap()); + assert!(same_file::is_same_file(Path::new(&stripped_path), &dir).unwrap()); + assert!(!stripped_path.starts_with(LOCAL_UNC), "The path was not stripped."); } else { assert_eq!( strip_unc(&canonicalize(Path::new(&dir)).unwrap()), @@ -281,9 +281,9 @@ mod tests { remove_dir_all(&dir).expect("Could not free test directory"); } create_dir(&dir).expect("Could not create test directory"); - - let canonicalized_path = canonicalize(Path::new(&dir)).unwrap(); - assert!(same_file::is_same_file(Path::new(&canonicalized_path),&dir).unwrap()); + + let canonicalized_path = canonicalize(Path::new(&dir)).unwrap(); + assert!(same_file::is_same_file(Path::new(&canonicalized_path), &dir).unwrap()); assert!(canonicalized_path.to_str().unwrap().starts_with(LOCAL_UNC)); remove_dir_all(&dir).unwrap();