Skip to content
16 changes: 8 additions & 8 deletions src/Plugins/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Pagination {
return false;
}

isFiltered(value) {
isIncluded(value) {
const hasInclude = "include" in this.data.pagination;
const hasExclude = "exclude" in this.data.pagination;
if (hasInclude && hasExclude) {
Expand All @@ -107,27 +107,27 @@ class Pagination {
if (hasInclude) {
let included = this.data.pagination.include;
if (Array.isArray(included)) {
return !included.includes(value);
return included.includes(value);
}
return included !== value;
return included === value;
}
if (hasExclude) {
let excluded = this.data.pagination.exclude;
if (Array.isArray(excluded)) {
return excluded.includes(value);
return !excluded.includes(value);
}
return excluded === value;
return excluded !== value;
}

// Let's keep this code for backwards compatibility to V2.

@uncenter uncenter Dec 19, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this old filter property logic now I think.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be happy to do so, but I think this should be communicated, since it affects the public API of this plugin. Is there a way to log warnings if someone still uses filters?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we add a warning when someone uses filter that says "The filter Pagination property has been deprecated in Eleventy v3. You can replace it with exclude for the same effect".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly. My question is, if there is a better way than throwing an error or using console.warn for this.

@uncenter uncenter Dec 19, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anywhere else where we are throwing an error or console.warn-ing for a deprecation. Seems like those just get tagged as deprecated with JSDoc but aren't removed or changed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @zachleat, how would you want me to handle this here?
Maybe you even have an opinion on doing a breaking change.

// TODO remove in 3.0
if ("filter" in this.data.pagination) {
let filtered = this.data.pagination.filter;
if (Array.isArray(filtered)) {
return filtered.indexOf(value) > -1;
return filtered.indexOf(value) === -1;
}

return filtered === value;
return filtered !== value;
}

return false;
Comment thread
Snapstromegon marked this conversation as resolved.
Outdated
Expand Down Expand Up @@ -189,7 +189,7 @@ class Pagination {
this.data.pagination.include ||
this.data.pagination.exclude
) {
result = result.filter((value) => !this.isFiltered(value));
result = result.filter((value) => this.isIncluded(value));
}

return result;
Expand Down