Do not paginate drafts

Fix #495
This commit is contained in:
Vincent Prouillet 2018-10-23 13:37:23 +02:00
parent 19b4341957
commit dc94aa219b
2 changed files with 7 additions and 0 deletions

View file

@ -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 - Do not have a trailing slash for the RSS permalinks
- `serve` will now try to find other ports than 1111 rather than panicking - `serve` will now try to find other ports than 1111 rather than panicking
- Ensure content directory exists before rendering aliases - Ensure content directory exists before rendering aliases
- Do not include drafts in pagination
## 0.4.2 (2018-09-03) ## 0.4.2 (2018-09-03)

View file

@ -108,6 +108,9 @@ impl<'a> Paginator<'a> {
for key in self.all_pages { for key in self.all_pages {
let page = library.get_page_by_key(*key); let page = library.get_page_by_key(*key);
if page.is_draft() {
continue;
}
current_page.push(page.to_serialized_basic(library)); current_page.push(page.to_serialized_basic(library));
if current_page.len() == self.paginate_by { 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()); 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); let mut section = create_section(is_index);
section.pages = library.pages().keys().collect(); section.pages = library.pages().keys().collect();
library.insert_section(section.clone()); library.insert_section(section.clone());