Skip to content

Commit 59aeb87

Browse files
uioleeyoshinorin
andauthored
fix: pagination_dir setting (#98)
Signed-off-by: yoshinorin <[email protected]> Co-authored-by: yoshinorin <[email protected]>
1 parent beaa06c commit 59aeb87

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/generator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = function(locals) {
88

99
posts.data.sort((a, b) => (b.sticky || 0) - (a.sticky || 0));
1010

11-
const paginationDir = config.pagination_dir || 'page';
11+
const paginationDir = config.index_generator.pagination_dir || config.pagination_dir || 'page';
1212
const path = config.index_generator.path || '';
1313

1414
return pagination(path, posts, {

test/index.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ describe('Index generator', () => {
123123
});
124124
});
125125

126-
it('custom pagination_dir', () => {
126+
it('custom pagination_dir - global setting', () => {
127127
hexo.config.index_generator.per_page = 1;
128128
hexo.config.pagination_dir = 'yo';
129129

@@ -135,4 +135,18 @@ describe('Index generator', () => {
135135

136136
});
137137

138+
it('custom pagination_dir - plugin setting', () => {
139+
hexo.config.index_generator.per_page = 1;
140+
hexo.config.index_generator.pagination_dir = 'yoyo';
141+
142+
const result = generator(locals);
143+
144+
result[0].path.should.eql('');
145+
result[1].path.should.eql('yoyo/2/');
146+
result[2].path.should.eql('yoyo/3/');
147+
148+
// Restore config
149+
hexo.config.index_generator.per_page = 10;
150+
hexo.config.index_generator.pagination_dir = 'page';
151+
});
138152
});

0 commit comments

Comments
 (0)