first commit
This commit is contained in:
7
node_modules/hexo-generator-index/LICENSE
generated
vendored
Normal file
7
node_modules/hexo-generator-index/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.
|
||||
63
node_modules/hexo-generator-index/README.md
generated
vendored
Normal file
63
node_modules/hexo-generator-index/README.md
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
# hexo-generator-index
|
||||
|
||||
[](https://github.com/hexojs/hexo-generator-index/actions?query=workflow%3ATester)
|
||||
[](https://www.npmjs.com/package/hexo-generator-index)
|
||||
[](https://coveralls.io/r/hexojs/hexo-generator-index?branch=master)
|
||||
|
||||
Index generator for [Hexo].
|
||||
|
||||
It generates an archive of posts on your homepage, according to the `index` or `archive` layout of your theme.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install hexo-generator-index --save
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
Add or modify the following section to your root `_config.yml` file.
|
||||
|
||||
```yaml
|
||||
index_generator:
|
||||
path: ""
|
||||
per_page: 10
|
||||
order_by: -date
|
||||
pagination_dir: page
|
||||
layout: ["index", "archive"]
|
||||
```
|
||||
|
||||
- **path**: Root path for your blog's index page.
|
||||
- default: `""`
|
||||
- **per_page**: Posts displayed per page.
|
||||
- default: [`config.per_page`](https://hexo.io/docs/configuration.html#Pagination) as specified in the official Hexo docs (if present), otherwise `10`
|
||||
- `0` disables pagination.
|
||||
- **order_by**: Posts order.
|
||||
- default: `-date` (date descending)
|
||||
- **pagination_dir**: URL format.
|
||||
- default: `page`
|
||||
- e.g. set `awesome-page` makes the URL ends with `awesome-page/<page number>` for second page and beyond.
|
||||
- **layout**: custom layout.
|
||||
- defalut: `["index", "archive"]`
|
||||
|
||||
## Usage
|
||||
|
||||
The `sticky` parameter in the post [Front-matter](https://hexo.io/docs/front-matter) will be used to pin the post to the top of the index page. Higher `sticky` means that it will be ranked first.
|
||||
|
||||
```yml
|
||||
---
|
||||
title: Hello World
|
||||
date: 2013/7/13 20:46:25
|
||||
sticky: 100
|
||||
---
|
||||
```
|
||||
|
||||
## Note
|
||||
|
||||
If your theme define a non-archive `index` layout (e.g. About Me page), this plugin would follow that layout instead and not generate an archive. In that case, use [hexo-generator-archive](https://github.com/hexojs/hexo-generator-archive) to generate an archive according to the `archive` layout.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
[Hexo]: https://hexo.io/
|
||||
11
node_modules/hexo-generator-index/index.js
generated
vendored
Normal file
11
node_modules/hexo-generator-index/index.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/* global hexo */
|
||||
|
||||
'use strict';
|
||||
|
||||
hexo.config.index_generator = Object.assign({
|
||||
per_page: typeof hexo.config.per_page === 'undefined' ? 10 : hexo.config.per_page,
|
||||
order_by: '-date',
|
||||
layout: ['index', 'archive']
|
||||
}, hexo.config.index_generator);
|
||||
|
||||
hexo.extend.generator.register('index', require('./lib/generator'));
|
||||
22
node_modules/hexo-generator-index/lib/generator.js
generated
vendored
Normal file
22
node_modules/hexo-generator-index/lib/generator.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
const pagination = require('hexo-pagination');
|
||||
|
||||
module.exports = function(locals) {
|
||||
const config = this.config;
|
||||
const posts = locals.posts.sort(config.index_generator.order_by);
|
||||
|
||||
posts.data.sort((a, b) => (b.sticky || 0) - (a.sticky || 0));
|
||||
|
||||
const paginationDir = config.index_generator.pagination_dir || config.pagination_dir || 'page';
|
||||
const path = config.index_generator.path || '';
|
||||
|
||||
return pagination(path, posts, {
|
||||
perPage: config.index_generator.per_page,
|
||||
layout: config.index_generator.layout || ['index', 'archive'],
|
||||
format: paginationDir + '/%d/',
|
||||
data: {
|
||||
__index: true
|
||||
}
|
||||
});
|
||||
};
|
||||
42
node_modules/hexo-generator-index/package.json
generated
vendored
Normal file
42
node_modules/hexo-generator-index/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "hexo-generator-index",
|
||||
"version": "4.0.0",
|
||||
"description": "Index 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/"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"repository": "hexojs/hexo-generator-index",
|
||||
"homepage": "https://hexo.io/",
|
||||
"keywords": [
|
||||
"hexo",
|
||||
"generator",
|
||||
"index",
|
||||
"home"
|
||||
],
|
||||
"author": "Tommy Chen <tommy351@gmail.com> (https://zespia.tw)",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"c8": "^10.1.2",
|
||||
"chai": "^4.3.6",
|
||||
"eslint": "^8.25.0",
|
||||
"eslint-config-hexo": "^5.0.0",
|
||||
"hexo": "^7.0.0",
|
||||
"mocha": "^10.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"hexo-pagination": "3.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user