Skip to content

Commit

Permalink
Updates #1698 to defer to approach from #2208
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed May 11, 2022
1 parent 2dc653a commit ff6bd8d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
8 changes: 2 additions & 6 deletions src/Plugins/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class Pagination {

const chunks = lodashChunk(this.target, this.size);

if (this.data.pagination && this.data.pagination.renderEmpty) {
if (this.data.pagination && this.data.pagination.generatePageOnEmptyData) {
return chunks.length ? chunks : [[]];
} else {
return chunks;
Expand Down Expand Up @@ -337,11 +337,7 @@ class Pagination {
// so that we don’t have the memory cost of the full template (and can reuse the parent
// template for some things)

for (
let pageNumber = 0;
pageNumber < items.length;
pageNumber++
) {
for (let pageNumber = 0; pageNumber < items.length; pageNumber++) {
let cloned = this.template.clone();

if (pageNumber > 0 && !hasPermalinkField && !hasComputedPermalinkField) {
Expand Down
6 changes: 3 additions & 3 deletions test/PaginationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test("Empty paged data", async (t) => {
t.is((await paging.getPageTemplates()).length, 0);
});

test("Empty paged data with pageOnEmptyData enabled", async (t) => {
test("Empty paged data with generatePageOnEmptyData enabled", async (t) => {
let eleventyConfig = new TemplateConfig();
let tmpl = getNewTemplate(
"./test/stubs/paged/paged-empty-pageonemptydata.njk",
Expand All @@ -79,8 +79,8 @@ test("Empty paged data with pageOnEmptyData enabled", async (t) => {
let paging = new Pagination(data, tmpl.config);
paging.setTemplate(tmpl);

t.is(paging.getPageCount(), 0);
t.is(paging.pagedItems.length, 0);
t.is(paging.getPageCount(), 1);
t.is(paging.pagedItems.length, 1);
t.is((await paging.getPageTemplates()).length, 1);
});

Expand Down
2 changes: 1 addition & 1 deletion test/stubs/paged/paged-empty-pageonemptydata.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pagination:
data: items
size: 1
pageOnEmptyData: true
generatePageOnEmptyData: true
items: []
---
<ol>{% for item in pagination.items %}<li>{{ item }}</li>{% endfor %}</ol>

0 comments on commit ff6bd8d

Please sign in to comment.