From ccaf36ee941464ab917534dbc91a1a2ee9225bc8 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Tue, 18 Sep 2018 19:18:50 +0200 Subject: [PATCH] Avoid the use of enumerate in render_paginated --- components/pagination/src/lib.rs | 2 +- components/site/src/lib.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/pagination/src/lib.rs b/components/pagination/src/lib.rs index ac95b3d0..1ffb3b9c 100644 --- a/components/pagination/src/lib.rs +++ b/components/pagination/src/lib.rs @@ -33,7 +33,7 @@ enum PaginationRoot<'a> { #[derive(Clone, Debug, PartialEq, Serialize)] pub struct Pager<'a> { /// The page number in the paginator (1-indexed) - index: usize, + pub index: usize, /// Permalink to that page permalink: String, /// Path to that page diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index c0a05598..196e7ed3 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -905,12 +905,11 @@ impl Site { paginator .pagers .par_iter() - .enumerate() - .map(|(i, pager)| { - let page_path = folder_path.join(&format!("{}", i + 1)); + .map(|pager| { + let page_path = folder_path.join(&format!("{}", pager.index)); create_directory(&page_path)?; let output = paginator.render_pager(pager, &self.config, &self.tera)?; - if i > 0 { + if pager.index > 1 { create_file(&page_path.join("index.html"), &self.inject_livereload(output))?; } else { create_file(&output_path.join("index.html"), &self.inject_livereload(output))?;