From 6903975202e0114a815e2266dce1bdd89a00866a Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Wed, 19 Sep 2018 09:24:35 +0200 Subject: [PATCH] Do not copy pages of sections when rendering taxonomies --- components/content/src/section.rs | 22 ++++++++++++++++++++++ components/pagination/src/lib.rs | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/components/content/src/section.rs b/components/content/src/section.rs index 0039555f..0cdc70e5 100644 --- a/components/content/src/section.rs +++ b/components/content/src/section.rs @@ -182,6 +182,28 @@ impl Section { .map(|filename| self.path.clone() + filename) .collect() } + + pub fn clone_without_pages(&self) -> Section { + let mut subsections = vec![]; + for subsection in &self.subsections { + subsections.push(subsection.clone_without_pages()); + } + + Section { + file: self.file.clone(), + meta: self.meta.clone(), + path: self.path.clone(), + components: self.components.clone(), + permalink: self.permalink.clone(), + raw_content: self.raw_content.clone(), + content: self.content.clone(), + assets: self.assets.clone(), + toc: self.toc.clone(), + subsections, + pages: vec![], + ignored_pages: vec![], + } + } } impl ser::Serialize for Section { diff --git a/components/pagination/src/lib.rs b/components/pagination/src/lib.rs index 1ffb3b9c..ff9347fc 100644 --- a/components/pagination/src/lib.rs +++ b/components/pagination/src/lib.rs @@ -215,7 +215,7 @@ impl<'a> Paginator<'a> { context.insert("config", &config); let template_name = match self.root { PaginationRoot::Section(s) => { - context.insert("section", &s); + context.insert("section", &s.clone_without_pages()); s.get_template_name() } PaginationRoot::Taxonomy(t) => {