Skip to content

Commit

Permalink
Implement Default for LanguageOptions (#2145)
Browse files Browse the repository at this point in the history
Closes #2137
  • Loading branch information
justint authored and Keats committed Mar 19, 2023
1 parent a4a85fe commit d52a071
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion components/config/src/config/languages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
use crate::config::search;
use crate::config::taxonomies;

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Default)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default)]
pub struct LanguageOptions {
/// Title of the site. Defaults to None
Expand Down Expand Up @@ -96,6 +96,21 @@ impl LanguageOptions {
}
}

impl Default for LanguageOptions {
fn default() -> LanguageOptions {
LanguageOptions {
title: None,
description: None,
generate_feed: false,
feed_filename: "atom.xml".to_string(),
taxonomies: vec![],
build_search_index: false,
search: search::Search::default(),
translations: HashMap::new(),
}
}
}

/// We want to ensure the language codes are valid ones
pub fn validate_code(code: &str) -> Result<()> {
if LanguageIdentifier::from_bytes(code.as_bytes()).is_err() {
Expand Down

0 comments on commit d52a071

Please sign in to comment.