Skip to content

Commit

Permalink
Merge branch 'master' into page_dir
Browse files Browse the repository at this point in the history
Signed-off-by: yoshinorin <[email protected]>
  • Loading branch information
yoshinorin authored Jul 8, 2024
2 parents 818fa98 + beaa06c commit d7ed8f2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 39 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ jobs:
linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v2
- uses: actions/checkout@v4
- name: Use Node.js 18
uses: actions/setup-node@v4
with:
node-version: '14.x'
node-version: "18"
- name: Install Dependencies
run: npm install
- name: Lint
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/tester.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: ['14.x', '16.x', '18.x']
node-version: [18, 20]
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
Expand All @@ -27,11 +27,11 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node-version: ['14.x']
node-version: [18]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
Expand All @@ -41,6 +41,6 @@ jobs:
env:
CI: true
- name: Coveralls
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.github_token }}
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ It generates an archive of posts on your homepage, according to the `index` or `

## Installation

``` bash
$ npm install hexo-generator-index --save
```bash
npm install hexo-generator-index --save
```

## Options

Add or modify the following section to your root _config.yml file
Add or modify the following section to your root `_config.yml` file.

``` yaml
```yaml
index_generator:
path: ''
path: ""
per_page: 10
order_by: -date
pagination_dir: page
```
- **path**: Root path for your blog's index page.
- default: ""
- **path**: Root path for your blog's index page.
- default: `""`
- **per_page**: Posts displayed per page.
- default: [`config.per_page`](https://hexo.io/docs/configuration.html#Pagination) as specified in the official Hexo docs (if present), otherwise `10`
- `0` disables pagination
- **order_by**: Posts order.
- default: date descending
- `0` disables pagination.
- **order_by**: Posts order.
- default: `-date` (date descending)
- **pagination_dir**: URL format.
- default: 'page'
- `awesome-page` makes the URL ends with 'awesome-page/<page number>' for second page and beyond.
- default: `page`
- e.g. set `awesome-page` makes the URL ends with `awesome-page/<page number>` for second page and beyond.

## Usage

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"lib/"
],
"engines": {
"node": ">=14"
"node": ">=18"
},
"repository": "hexojs/hexo-generator-index",
"homepage": "https://hexo.io/",
Expand All @@ -29,7 +29,7 @@
"author": "Tommy Chen <[email protected]> (https://zespia.tw)",
"license": "MIT",
"devDependencies": {
"c8": "^9.0.0",
"c8": "^10.1.2",
"chai": "^4.3.6",
"eslint": "^8.25.0",
"eslint-config-hexo": "^5.0.0",
Expand Down
20 changes: 6 additions & 14 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ describe('Index generator', () => {
locals;

// Default config
hexo.config.index_generator = {
const default_index_generator = Object.freeze({
per_page: 10,
order_by: '-date'
};
});

beforeEach(() => {
hexo.config.index_generator = {...default_index_generator};
});

before(() => hexo.init().then(() => Post.insert([
{source: 'foo', slug: 'foo', date: 1e8, order: 0},
Expand Down Expand Up @@ -57,8 +61,6 @@ describe('Index generator', () => {
result[1].data.next_link.should.eql('');
result[1].data.__index.should.be.true;

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

it('pagination disabled', () => {
Expand All @@ -81,8 +83,6 @@ describe('Index generator', () => {
result[0].data.next_link.should.eql('');
result[0].data.__index.should.be.true;

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

describe('order', () => {
Expand All @@ -109,8 +109,6 @@ describe('Index generator', () => {
result[0].data.posts.eq(1).source.should.eql('baz');
result[0].data.posts.eq(2).source.should.eql('bar');

// Restore config
delete hexo.config.index_generator.order_by;
});

it('custom order - invalid order key', () => {
Expand All @@ -122,8 +120,6 @@ describe('Index generator', () => {
result[0].data.posts.eq(1).source.should.eql('bar');
result[0].data.posts.eq(2).source.should.eql('baz');

// Restore config
delete hexo.config.index_generator.order_by;
});
});

Expand All @@ -137,9 +133,6 @@ describe('Index generator', () => {
result[1].path.should.eql('yo/2/');
result[2].path.should.eql('yo/3/');

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

it('custom pagination_dir - plugin setting', () => {
Expand All @@ -156,5 +149,4 @@ describe('Index generator', () => {
hexo.config.index_generator.per_page = 10;
hexo.config.index_generator.pagination_dir = 'page';
});

});

0 comments on commit d7ed8f2

Please sign in to comment.