From dc94aa219b93f77472e457881c0c1b64b3bcb476 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Tue, 23 Oct 2018 13:37:23 +0200 Subject: [PATCH] Do not paginate drafts Fix #495 --- CHANGELOG.md | 1 + components/library/src/pagination/mod.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a6dd86..d769038 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ sections up to the index to be used with the `get_section` Tera function - Do not have a trailing slash for the RSS permalinks - `serve` will now try to find other ports than 1111 rather than panicking - Ensure content directory exists before rendering aliases +- Do not include drafts in pagination ## 0.4.2 (2018-09-03) diff --git a/components/library/src/pagination/mod.rs b/components/library/src/pagination/mod.rs index 3262009..cebefb6 100644 --- a/components/library/src/pagination/mod.rs +++ b/components/library/src/pagination/mod.rs @@ -108,6 +108,9 @@ impl<'a> Paginator<'a> { for key in self.all_pages { let page = library.get_page_by_key(*key); + if page.is_draft() { + continue; + } current_page.push(page.to_serialized_basic(library)); if current_page.len() == self.paginate_by { @@ -242,6 +245,9 @@ mod tests { library.insert_page(Page::default()); library.insert_page(Page::default()); library.insert_page(Page::default()); + let mut draft = Page::default(); + draft.meta.draft = true; + library.insert_page(draft); let mut section = create_section(is_index); section.pages = library.pages().keys().collect(); library.insert_section(section.clone());