Skip to content

Commit d7ed8f2

Browse files
authored
Merge branch 'master' into page_dir
Signed-off-by: yoshinorin <[email protected]>
2 parents 818fa98 + beaa06c commit d7ed8f2

File tree

5 files changed

+31
-39
lines changed

5 files changed

+31
-39
lines changed

.github/workflows/linter.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ jobs:
66
linter:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
10-
- name: Use Node.js 14.x
11-
uses: actions/setup-node@v2
9+
- uses: actions/checkout@v4
10+
- name: Use Node.js 18
11+
uses: actions/setup-node@v4
1212
with:
13-
node-version: '14.x'
13+
node-version: "18"
1414
- name: Install Dependencies
1515
run: npm install
1616
- name: Lint

.github/workflows/tester.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ jobs:
88
strategy:
99
matrix:
1010
os: [ubuntu-latest, windows-latest, macos-latest]
11-
node-version: ['14.x', '16.x', '18.x']
11+
node-version: [18, 20]
1212
fail-fast: false
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515
- name: Use Node.js ${{ matrix.node-version }}
16-
uses: actions/setup-node@v2
16+
uses: actions/setup-node@v4
1717
with:
1818
node-version: ${{ matrix.node-version }}
1919
- name: Install Dependencies
@@ -27,11 +27,11 @@ jobs:
2727
strategy:
2828
matrix:
2929
os: [ubuntu-latest]
30-
node-version: ['14.x']
30+
node-version: [18]
3131
steps:
32-
- uses: actions/checkout@v2
32+
- uses: actions/checkout@v4
3333
- name: Use Node.js ${{ matrix.node-version }}
34-
uses: actions/setup-node@v2
34+
uses: actions/setup-node@v4
3535
with:
3636
node-version: ${{ matrix.node-version }}
3737
- name: Install Dependencies
@@ -41,6 +41,6 @@ jobs:
4141
env:
4242
CI: true
4343
- name: Coveralls
44-
uses: coverallsapp/github-action@master
44+
uses: coverallsapp/github-action@v2
4545
with:
4646
github-token: ${{ secrets.github_token }}

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,32 @@ It generates an archive of posts on your homepage, according to the `index` or `
1010

1111
## Installation
1212

13-
``` bash
14-
$ npm install hexo-generator-index --save
13+
```bash
14+
npm install hexo-generator-index --save
1515
```
1616

1717
## Options
1818

19-
Add or modify the following section to your root _config.yml file
19+
Add or modify the following section to your root `_config.yml` file.
2020

21-
``` yaml
21+
```yaml
2222
index_generator:
23-
path: ''
23+
path: ""
2424
per_page: 10
2525
order_by: -date
2626
pagination_dir: page
2727
```
2828
29-
- **path**: Root path for your blog's index page.
30-
- default: ""
29+
- **path**: Root path for your blog's index page.
30+
- default: `""`
3131
- **per_page**: Posts displayed per page.
3232
- default: [`config.per_page`](https://hexo.io/docs/configuration.html#Pagination) as specified in the official Hexo docs (if present), otherwise `10`
33-
- `0` disables pagination
34-
- **order_by**: Posts order.
35-
- default: date descending
33+
- `0` disables pagination.
34+
- **order_by**: Posts order.
35+
- default: `-date` (date descending)
3636
- **pagination_dir**: URL format.
37-
- default: 'page'
38-
- `awesome-page` makes the URL ends with 'awesome-page/<page number>' for second page and beyond.
37+
- default: `page`
38+
- e.g. set `awesome-page` makes the URL ends with `awesome-page/<page number>` for second page and beyond.
3939

4040
## Usage
4141

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"lib/"
1717
],
1818
"engines": {
19-
"node": ">=14"
19+
"node": ">=18"
2020
},
2121
"repository": "hexojs/hexo-generator-index",
2222
"homepage": "https://hexo.io/",
@@ -29,7 +29,7 @@
2929
"author": "Tommy Chen <[email protected]> (https://zespia.tw)",
3030
"license": "MIT",
3131
"devDependencies": {
32-
"c8": "^9.0.0",
32+
"c8": "^10.1.2",
3333
"chai": "^4.3.6",
3434
"eslint": "^8.25.0",
3535
"eslint-config-hexo": "^5.0.0",

test/index.js

+6-14
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ describe('Index generator', () => {
1111
locals;
1212

1313
// Default config
14-
hexo.config.index_generator = {
14+
const default_index_generator = Object.freeze({
1515
per_page: 10,
1616
order_by: '-date'
17-
};
17+
});
18+
19+
beforeEach(() => {
20+
hexo.config.index_generator = {...default_index_generator};
21+
});
1822

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

60-
// Restore config
61-
hexo.config.index_generator.per_page = 10;
6264
});
6365

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

84-
// Restore config
85-
hexo.config.index_generator.per_page = 10;
8686
});
8787

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

112-
// Restore config
113-
delete hexo.config.index_generator.order_by;
114112
});
115113

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

125-
// Restore config
126-
delete hexo.config.index_generator.order_by;
127123
});
128124
});
129125

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

140-
// Restore config
141-
hexo.config.index_generator.per_page = 10;
142-
hexo.config.pagination_dir = 'page';
143136
});
144137

145138
it('custom pagination_dir - plugin setting', () => {
@@ -156,5 +149,4 @@ describe('Index generator', () => {
156149
hexo.config.index_generator.per_page = 10;
157150
hexo.config.index_generator.pagination_dir = 'page';
158151
});
159-
160152
});

0 commit comments

Comments
 (0)