Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added "explicit_paging" and "overwrite_latest" options #90

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
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,12 +18,20 @@ $ npm install hexo-generator-tag --save
tag_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)
- **enable_index_page**: Generate a `/[config.tag_dir]/index.html` page.
- Support following template layout: `tag-index`, `tag`, `archive`, `index`
- **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 @@ -7,6 +7,10 @@ module.exports = function(locals) {
const perPage = config.tag_generator.per_page;
const paginationDir = config.pagination_dir || 'page';
const orderBy = config.tag_generator.order_by || '-date';
const explicitPaging = config.tag_generator.explicit_paging || false;
const renameLast = config.tag_generator.rename_last || false;
const localizedLast = config.tag_generator.localized_last || 'last';
const verbose = config.tag_generator.verbose || false;
const tags = locals.tags;
let tagDir;

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