Add back subsections in basic section ser

Closes #733
This commit is contained in:
Vincent Prouillet 2019-08-10 19:21:53 +02:00
parent c503a9fe5d
commit e231818718
2 changed files with 13 additions and 15 deletions

View file

@ -254,23 +254,21 @@ impl<'a> SerializingSection<'a> {
} }
} }
/// Same as from_section but doesn't fetch pages and sections /// Same as from_section but doesn't fetch pages
pub fn from_section_basic(section: &'a Section, library: Option<&'a Library>) -> Self { pub fn from_section_basic(section: &'a Section, library: Option<&'a Library>) -> Self {
let ancestors = if let Some(ref lib) = library { let mut ancestors = vec![];
section let mut translations = vec![];
let mut subsections = vec![];
if let Some(ref lib) = library {
ancestors = section
.ancestors .ancestors
.iter() .iter()
.map(|k| lib.get_section_by_key(*k).file.relative.clone()) .map(|k| lib.get_section_by_key(*k).file.relative.clone())
.collect() .collect();
} else { translations = TranslatedContent::find_all_sections(section, lib);
vec![] subsections =
}; section.subsections.iter().map(|k| lib.get_section_path_by_key(*k)).collect();
}
let translations = if let Some(ref lib) = library {
TranslatedContent::find_all_sections(section, lib)
} else {
vec![]
};
SerializingSection { SerializingSection {
relative_path: &section.file.relative, relative_path: &section.file.relative,
@ -287,7 +285,7 @@ impl<'a> SerializingSection<'a> {
assets: &section.serialized_assets, assets: &section.serialized_assets,
lang: &section.lang, lang: &section.lang,
pages: vec![], pages: vec![],
subsections: vec![], subsections,
translations, translations,
} }
} }

View file

@ -421,7 +421,7 @@ mod tests {
if x.kind.lang == "en" { if x.kind.lang == "en" {
t = Some(x) t = Some(x)
} }
}, }
"categories" => c = Some(x), "categories" => c = Some(x),
"auteurs" => a = Some(x), "auteurs" => a = Some(x),
_ => unreachable!(), _ => unreachable!(),