@@ -2,6 +2,7 @@ const lodashChunk = require("lodash/chunk");
2
2
const lodashGet = require ( "lodash/get" ) ;
3
3
const lodashSet = require ( "lodash/set" ) ;
4
4
const EleventyBaseError = require ( "../EleventyBaseError" ) ;
5
+ const getPaginationDataKey = require ( "../Util/GetPaginationDataKey" ) ;
5
6
6
7
class PaginationConfigError extends EleventyBaseError { }
7
8
class PaginationError extends EleventyBaseError { }
@@ -30,13 +31,13 @@ class Pagination {
30
31
return Pagination . hasPagination ( this . data ) ;
31
32
}
32
33
33
- circularReferenceCheck ( data ) {
34
- if ( data . eleventyExcludeFromCollections ) {
34
+ circularReferenceCheck ( ) {
35
+ if ( this . data . eleventyExcludeFromCollections ) {
35
36
return ;
36
37
}
37
38
38
- let key = data . pagination . data ;
39
- let tags = data . tags || [ ] ;
39
+ let key = getPaginationDataKey ( this . data ) ;
40
+ let tags = this . data . tags || [ ] ;
40
41
for ( let tag of tags ) {
41
42
if ( `collections.${ tag } ` === key ) {
42
43
throw new PaginationError (
@@ -63,7 +64,7 @@ class Pagination {
63
64
} else if ( ! ( "size" in data . pagination ) ) {
64
65
throw new Error ( "Missing pagination size in front matter data." ) ;
65
66
}
66
- this . circularReferenceCheck ( data ) ;
67
+ this . circularReferenceCheck ( ) ;
67
68
68
69
this . size = data . pagination . size ;
69
70
this . alias = data . pagination . alias ;
@@ -76,10 +77,6 @@ class Pagination {
76
77
this . template = tmpl ;
77
78
}
78
79
79
- _getDataKey ( ) {
80
- return this . data . pagination . data ;
81
- }
82
-
83
80
doResolveToObjectValues ( ) {
84
81
if ( "resolve" in this . data . pagination ) {
85
82
return this . data . pagination . resolve === "values" ;
@@ -102,7 +99,7 @@ class Pagination {
102
99
103
100
_resolveItems ( ) {
104
101
let notFoundValue = "__NOT_FOUND_ERROR__" ;
105
- let key = this . _getDataKey ( ) ;
102
+ let key = getPaginationDataKey ( this . data ) ;
106
103
let fullDataSet = lodashGet ( this . data , key , notFoundValue ) ;
107
104
if ( fullDataSet === notFoundValue ) {
108
105
throw new Error (
@@ -195,7 +192,7 @@ class Pagination {
195
192
196
193
let override = {
197
194
pagination : {
198
- data : this . data . pagination . data ,
195
+ data : getPaginationDataKey ( this . data ) ,
199
196
size : this . data . pagination . size ,
200
197
alias : this . alias ,
201
198
0 commit comments