Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ $ npm install hexo-generator-category --save
category_generator:
per_page: 10
order_by: -date
explicit_paging: false
rename_last: false
localized_last: 'last'
verbose: false
```

- **per_page**: Posts displayed per page. (0 = disable pagination)
- **order_by**: Posts order. (Order by date descending by default)
- **explicit_paging**: Explicit paging. (Number the first page. e.g. `page/1/index.html`)
- **rename_last**: Set the latest page name. (`page/last/index.html` in place of `page/N/index.html`). If there is a single page it requires explicit_paging=true`.
- **localized_last**: Localize the last page name. (`page/最後/index.html` in place of `page/last/index.html`).
- **verbose**: verbose output. (Output all generated routes)

## License

Expand Down
8 changes: 8 additions & 0 deletions lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ const pagination = require('hexo-pagination');
module.exports = function(locals) {
const config = this.config;
const perPage = config.category_generator.per_page;
const explicitPaging = config.category_generator.explicit_paging || false;
const renameLast = config.category_generator.rename_last || false;
const localizedLast = config.category_generator.localized_last || 'last';
const verbose = config.category_generator.verbose || false;
const paginationDir = config.pagination_dir || 'page';
const orderBy = config.category_generator.order_by || '-date';

Expand All @@ -16,6 +20,10 @@ module.exports = function(locals) {
perPage,
layout: ['category', 'archive', 'index'],
format: paginationDir + '/%d/',
explicitPaging: explicitPaging,
renameLast: renameLast,
localizedLast: localizedLast,
verbose: verbose,
data: {
category: category.name
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"mocha": "^10.0.0"
},
"dependencies": {
"hexo-pagination": "3.0.0"
"hexo-pagination": "4.0.0"
},
"engines": {
"node": ">=14"
Expand Down