Skip to content

Commit

Permalink
fix: pagination_dir setting (#98)
Browse files Browse the repository at this point in the history
Signed-off-by: yoshinorin <yoshinorin.net@outlook.com>
Co-authored-by: yoshinorin <yoshinorin.net@outlook.com>
  • Loading branch information
uiolee and yoshinorin authored Jul 8, 2024
1 parent beaa06c commit 59aeb87
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function(locals) {

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

const paginationDir = config.pagination_dir || 'page';
const paginationDir = config.index_generator.pagination_dir || config.pagination_dir || 'page';
const path = config.index_generator.path || '';

return pagination(path, posts, {
Expand Down
16 changes: 15 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('Index generator', () => {
});
});

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

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

});

it('custom pagination_dir - plugin setting', () => {
hexo.config.index_generator.per_page = 1;
hexo.config.index_generator.pagination_dir = 'yoyo';

const result = generator(locals);

result[0].path.should.eql('');
result[1].path.should.eql('yoyo/2/');
result[2].path.should.eql('yoyo/3/');

// Restore config
hexo.config.index_generator.per_page = 10;
hexo.config.index_generator.pagination_dir = 'page';
});
});

0 comments on commit 59aeb87

Please sign in to comment.