@@ -2,6 +2,7 @@ const lodashChunk = require("lodash/chunk");
22const lodashGet = require ( "lodash/get" ) ;
33const lodashSet = require ( "lodash/set" ) ;
44const EleventyBaseError = require ( "../EleventyBaseError" ) ;
5+ const getPaginationDataKey = require ( "../Util/GetPaginationDataKey" ) ;
56
67class PaginationConfigError extends EleventyBaseError { }
78class PaginationError extends EleventyBaseError { }
@@ -30,13 +31,13 @@ class Pagination {
3031 return Pagination . hasPagination ( this . data ) ;
3132 }
3233
33- circularReferenceCheck ( data ) {
34- if ( data . eleventyExcludeFromCollections ) {
34+ circularReferenceCheck ( ) {
35+ if ( this . data . eleventyExcludeFromCollections ) {
3536 return ;
3637 }
3738
38- let key = data . pagination . data ;
39- let tags = data . tags || [ ] ;
39+ let key = getPaginationDataKey ( this . data ) ;
40+ let tags = this . data . tags || [ ] ;
4041 for ( let tag of tags ) {
4142 if ( `collections.${ tag } ` === key ) {
4243 throw new PaginationError (
@@ -63,7 +64,7 @@ class Pagination {
6364 } else if ( ! ( "size" in data . pagination ) ) {
6465 throw new Error ( "Missing pagination size in front matter data." ) ;
6566 }
66- this . circularReferenceCheck ( data ) ;
67+ this . circularReferenceCheck ( ) ;
6768
6869 this . size = data . pagination . size ;
6970 this . alias = data . pagination . alias ;
@@ -76,10 +77,6 @@ class Pagination {
7677 this . template = tmpl ;
7778 }
7879
79- _getDataKey ( ) {
80- return this . data . pagination . data ;
81- }
82-
8380 doResolveToObjectValues ( ) {
8481 if ( "resolve" in this . data . pagination ) {
8582 return this . data . pagination . resolve === "values" ;
@@ -102,7 +99,7 @@ class Pagination {
10299
103100 _resolveItems ( ) {
104101 let notFoundValue = "__NOT_FOUND_ERROR__" ;
105- let key = this . _getDataKey ( ) ;
102+ let key = getPaginationDataKey ( this . data ) ;
106103 let fullDataSet = lodashGet ( this . data , key , notFoundValue ) ;
107104 if ( fullDataSet === notFoundValue ) {
108105 throw new Error (
@@ -195,7 +192,7 @@ class Pagination {
195192
196193 let override = {
197194 pagination : {
198- data : this . data . pagination . data ,
195+ data : getPaginationDataKey ( this . data ) ,
199196 size : this . data . pagination . size ,
200197 alias : this . alias ,
201198
0 commit comments