From e231818718eb2d2d5399c7d410487e0b06307abd Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Sat, 10 Aug 2019 19:21:53 +0200 Subject: [PATCH] Add back subsections in basic section ser Closes #733 --- components/library/src/content/ser.rs | 26 +++++++++++------------- components/library/src/taxonomies/mod.rs | 2 +- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/components/library/src/content/ser.rs b/components/library/src/content/ser.rs index f5304849..f28ccc01 100644 --- a/components/library/src/content/ser.rs +++ b/components/library/src/content/ser.rs @@ -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 { - let ancestors = if let Some(ref lib) = library { - section + let mut ancestors = vec![]; + let mut translations = vec![]; + let mut subsections = vec![]; + if let Some(ref lib) = library { + ancestors = section .ancestors .iter() .map(|k| lib.get_section_by_key(*k).file.relative.clone()) - .collect() - } else { - vec![] - }; - - let translations = if let Some(ref lib) = library { - TranslatedContent::find_all_sections(section, lib) - } else { - vec![] - }; + .collect(); + translations = TranslatedContent::find_all_sections(section, lib); + subsections = + section.subsections.iter().map(|k| lib.get_section_path_by_key(*k)).collect(); + } SerializingSection { relative_path: §ion.file.relative, @@ -287,7 +285,7 @@ impl<'a> SerializingSection<'a> { assets: §ion.serialized_assets, lang: §ion.lang, pages: vec![], - subsections: vec![], + subsections, translations, } } diff --git a/components/library/src/taxonomies/mod.rs b/components/library/src/taxonomies/mod.rs index 0bea5127..7486ce84 100644 --- a/components/library/src/taxonomies/mod.rs +++ b/components/library/src/taxonomies/mod.rs @@ -421,7 +421,7 @@ mod tests { if x.kind.lang == "en" { t = Some(x) } - }, + } "categories" => c = Some(x), "auteurs" => a = Some(x), _ => unreachable!(),