Skip to content

Commit 818fa98

Browse files
committed
fix: pagination_dir setting
1 parent f8ef61c commit 818fa98

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-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

+17-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ describe('Index generator', () => {
127127
});
128128
});
129129

130-
it('custom pagination_dir', () => {
130+
it('custom pagination_dir - global setting', () => {
131131
hexo.config.index_generator.per_page = 1;
132132
hexo.config.pagination_dir = 'yo';
133133

@@ -141,4 +141,20 @@ describe('Index generator', () => {
141141
hexo.config.index_generator.per_page = 10;
142142
hexo.config.pagination_dir = 'page';
143143
});
144+
145+
it('custom pagination_dir - plugin setting', () => {
146+
hexo.config.index_generator.per_page = 1;
147+
hexo.config.index_generator.pagination_dir = 'yoyo';
148+
149+
const result = generator(locals);
150+
151+
result[0].path.should.eql('');
152+
result[1].path.should.eql('yoyo/2/');
153+
result[2].path.should.eql('yoyo/3/');
154+
155+
// Restore config
156+
hexo.config.index_generator.per_page = 10;
157+
hexo.config.index_generator.pagination_dir = 'page';
158+
});
159+
144160
});

0 commit comments

Comments
 (0)