first commit
This commit is contained in:
7
node_modules/hexo-generator-category/LICENSE
generated
vendored
Normal file
7
node_modules/hexo-generator-category/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2014 Tommy Chen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
30
node_modules/hexo-generator-category/README.md
generated
vendored
Normal file
30
node_modules/hexo-generator-category/README.md
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# hexo-generator-category
|
||||
|
||||
[](https://github.com/hexojs/hexo-generator-category/actions?query=workflow%3ATester)
|
||||
[](https://www.npmjs.com/package/hexo-generator-category)
|
||||
[](https://coveralls.io/r/hexojs/hexo-generator-category?branch=master)
|
||||
|
||||
Category generator for [Hexo].
|
||||
|
||||
## Installation
|
||||
|
||||
``` bash
|
||||
$ npm install hexo-generator-category --save
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
``` yaml
|
||||
category_generator:
|
||||
per_page: 10
|
||||
order_by: -date
|
||||
```
|
||||
|
||||
- **per_page**: Posts displayed per page. (0 = disable pagination)
|
||||
- **order_by**: Posts order. (Order by date descending by default)
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
[Hexo]: https://hexo.io/
|
||||
9
node_modules/hexo-generator-category/index.js
generated
vendored
Normal file
9
node_modules/hexo-generator-category/index.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/* global hexo */
|
||||
|
||||
'use strict';
|
||||
|
||||
hexo.config.category_generator = Object.assign({
|
||||
per_page: typeof hexo.config.per_page === 'undefined' ? 10 : hexo.config.per_page
|
||||
}, hexo.config.category_generator);
|
||||
|
||||
hexo.extend.generator.register('category', require('./lib/generator'));
|
||||
26
node_modules/hexo-generator-category/lib/generator.js
generated
vendored
Normal file
26
node_modules/hexo-generator-category/lib/generator.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
const pagination = require('hexo-pagination');
|
||||
|
||||
module.exports = function(locals) {
|
||||
const config = this.config;
|
||||
const perPage = config.category_generator.per_page;
|
||||
const paginationDir = config.pagination_dir || 'page';
|
||||
const orderBy = config.category_generator.order_by || '-date';
|
||||
|
||||
return locals.categories.reduce((result, category) => {
|
||||
if (!category.length) return result;
|
||||
|
||||
const posts = category.posts.sort(orderBy);
|
||||
const data = pagination(category.path, posts, {
|
||||
perPage,
|
||||
layout: ['category', 'archive', 'index'],
|
||||
format: paginationDir + '/%d/',
|
||||
data: {
|
||||
category: category.name
|
||||
}
|
||||
});
|
||||
|
||||
return result.concat(data);
|
||||
}, []);
|
||||
};
|
||||
42
node_modules/hexo-generator-category/package.json
generated
vendored
Normal file
42
node_modules/hexo-generator-category/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "hexo-generator-category",
|
||||
"version": "2.0.0",
|
||||
"description": "Category generator for Hexo.",
|
||||
"main": "index",
|
||||
"scripts": {
|
||||
"eslint": "eslint .",
|
||||
"test": "mocha test/index.js",
|
||||
"test-cov": "c8 --reporter=lcovonly npm run test"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "./lib"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"repository": "hexojs/hexo-generator-category",
|
||||
"homepage": "https://hexo.io/",
|
||||
"keywords": [
|
||||
"hexo",
|
||||
"generator",
|
||||
"category"
|
||||
],
|
||||
"author": "Tommy Chen <tommy351@gmail.com> (https://zespia.tw)",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"c8": "^7.12.0",
|
||||
"chai": "^4.3.6",
|
||||
"coveralls": "^3.1.1",
|
||||
"eslint": "^8.25.0",
|
||||
"eslint-config-hexo": "^5.0.0",
|
||||
"hexo": "^6.3.0",
|
||||
"mocha": "^10.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"hexo-pagination": "3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user