diff --git a/README.md b/README.md index a973e3c..540c898 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,10 @@ archive_generator: monthly: true daily: false order_by: -date + explicit_paging: false + rename_last: false + localized_last: 'last' + verbose: false ``` - **enabled**: The default value is **true**, set to **false** if you do not want to enable the plugin @@ -30,6 +34,10 @@ archive_generator: - **monthly**: Generate monthly archive. - **daily**: Generate daily archive. - **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. (`page/last/index.html` in place of `page/N/index.html`). If there is a single page it requires explicitPaging=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 diff --git a/lib/generator.js b/lib/generator.js index 06ec549..be4b98e 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -11,6 +11,10 @@ module.exports = function(locals) { const paginationDir = config.pagination_dir || 'page'; const allPosts = locals.posts.sort(config.archive_generator.order_by || '-date'); const perPage = config.archive_generator.per_page; + const explicitPaging = config.archive_generator.explicit_paging || false; + const renameLast = config.archive_generator.rename_last || false; + const localizedLast = config.archive_generator.localized_last || 'last'; + const verbose = config.archive_generator.verbose || false; const result = []; if (!allPosts.length) return; @@ -20,12 +24,18 @@ module.exports = function(locals) { function generate(path, posts, options = {}) { options.archive = true; - result.push(...pagination(path, posts, { + const pages = pagination(path, posts, { perPage, layout: ['archive', 'index'], format: paginationDir + '/%d/', + explicitPaging: explicitPaging, + renameLast: renameLast, + localizedLast: localizedLast, + verbose: verbose, data: options - })); + }); + + result.push(...pages); } generate(archiveDir, allPosts); diff --git a/package-lock.json b/package-lock.json index b6f2d30..c772122 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "hexo-generator-archive", - "version": "1.0.0", + "version": "2.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "hexo-generator-archive", - "version": "1.0.0", + "version": "2.1.0", "license": "MIT", "dependencies": { - "hexo-pagination": "3.0.0" + "hexo-pagination": "^4.0.0" }, "devDependencies": { "c8": "^7.12.0", @@ -20,7 +20,7 @@ "mocha": "^10.0.0" }, "engines": { - "node": ">=12.13.0" + "node": ">=14" } }, "node_modules/@bcoe/v8-coverage": { @@ -1755,11 +1755,12 @@ } }, "node_modules/hexo-pagination": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/hexo-pagination/-/hexo-pagination-3.0.0.tgz", - "integrity": "sha512-8oo1iozloZo7TojPVYg4IxL3SJKCBdSJ908fTlIxIK7TWJIKdYnQlW31+12DBJ0NhVZA/lZisPObGF08wT8fKw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/hexo-pagination/-/hexo-pagination-4.0.0.tgz", + "integrity": "sha512-jNG6AX3EHzY3FRfdzB46tZ833CUX4WudZue3yv6kKaVCCWR61iwFL9LD6xQadvwHBuT1oHy444dJClWORG4sxg==", + "license": "MIT", "engines": { - "node": ">=14" + "node": ">=18" } }, "node_modules/hexo-util": { @@ -3314,6 +3315,21 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typescript": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, + "license": "Apache-2.0", + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -4886,9 +4902,9 @@ } }, "hexo-pagination": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/hexo-pagination/-/hexo-pagination-3.0.0.tgz", - "integrity": "sha512-8oo1iozloZo7TojPVYg4IxL3SJKCBdSJ908fTlIxIK7TWJIKdYnQlW31+12DBJ0NhVZA/lZisPObGF08wT8fKw==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/hexo-pagination/-/hexo-pagination-4.0.0.tgz", + "integrity": "sha512-jNG6AX3EHzY3FRfdzB46tZ833CUX4WudZue3yv6kKaVCCWR61iwFL9LD6xQadvwHBuT1oHy444dJClWORG4sxg==" }, "hexo-util": { "version": "2.7.0", @@ -5918,6 +5934,13 @@ "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true }, + "typescript": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, + "peer": true + }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/package.json b/package.json index 0367af5..2404d5a 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "mocha": "^10.0.0" }, "dependencies": { - "hexo-pagination": "3.0.0" + "hexo-pagination": "4.0.0" }, "engines": { "node": ">=14"