mirror of
https://github.com/getzola/zola
synced 2024-12-13 13:52:28 +00:00
Merge pull request #981 from GaaH/fail-if-lang-set-twice
Fail if a language is set both in config.default_languages and config…
This commit is contained in:
commit
ff6238afdd
1 changed files with 19 additions and 0 deletions
|
@ -215,6 +215,10 @@ impl Config {
|
|||
bail!("Highlight theme {} not available", config.highlight_theme)
|
||||
}
|
||||
|
||||
if config.languages.iter().any(|l| l.code == config.default_language) {
|
||||
bail!("Default language `{}` should not appear both in `config.default_language` and `config.languages`", config.default_language)
|
||||
}
|
||||
|
||||
config.build_timestamp = Some(Utc::now().timestamp());
|
||||
|
||||
if !config.ignored_content.is_empty() {
|
||||
|
@ -657,4 +661,19 @@ anchors = "off"
|
|||
assert_eq!(config.slugify.taxonomies, SlugifyStrategy::Safe);
|
||||
assert_eq!(config.slugify.anchors, SlugifyStrategy::Off);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn error_on_language_set_twice() {
|
||||
let config_str = r#"
|
||||
base_url = "https://remplace-par-ton-url.fr"
|
||||
default_language = "fr"
|
||||
languages = [
|
||||
{ code = "fr" },
|
||||
{ code = "en" },
|
||||
]
|
||||
"#;
|
||||
let config = Config::parse(config_str);
|
||||
let err = config.unwrap_err();
|
||||
assert_eq!("Default language `fr` should not appear both in `config.default_language` and `config.languages`", format!("{}", err));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue