Skip to content

Commit

Permalink
fix issue comment
Browse files Browse the repository at this point in the history
  • Loading branch information
renbaoshuo committed Jun 23, 2022
1 parent 409d95d commit 9d5d679
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/helper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = ctx => {
const is = require('./is');
helper.register('is_current', is.current);
helper.register('is_home', is.home);
helper.register('is_index', is.index);
helper.register('is_home_first_page', is.home_first_page);
helper.register('is_post', is.post);
helper.register('is_page', is.page);
helper.register('is_archive', is.archive);
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/helper/is.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function isHomeHelper() {
return Boolean(this.page.__index);
}

function isIndexHelper() {
function isHomeFirstPageHelper() {
return Boolean(this.page.__index) && this.page.current === 1;
}

Expand Down Expand Up @@ -83,7 +83,7 @@ function isTagHelper(tag) {

exports.current = isCurrentHelper;
exports.home = isHomeHelper;
exports.index = isIndexHelper;
exports.home_first_page = isHomeFirstPageHelper;
exports.post = isPostHelper;
exports.page = isPageHelper;
exports.archive = isArchiveHelper;
Expand Down
10 changes: 5 additions & 5 deletions test/scripts/helpers/is.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ describe('is', () => {
await is.home.call({page: {}}).should.be.false;
});

it('is_index', async () => {
await is.index.call({page: {__index: true, current: 1}}).should.be.true;
await is.index.call({page: {__index: true, current: 2}}).should.be.false;
await is.index.call({page: {__index: true}}).should.be.false;
await is.index.call({page: {}}).should.be.false;
it('is_home_first_page', async () => {
await is.home_first_page.call({page: {__index: true, current: 1}}).should.be.true;
await is.home_first_page.call({page: {__index: true, current: 2}}).should.be.false;
await is.home_first_page.call({page: {__index: true}}).should.be.false;
await is.home_first_page.call({page: {}}).should.be.false;
});

it('is_post', async () => {
Expand Down

0 comments on commit 9d5d679

Please sign in to comment.