hexo-generator-index
Advanced tools
Comparing version 1.0.0 to 2.0.0
'use strict'; | ||
const pagination = require('hexo-pagination'); | ||
const { sort } = require('timsort'); | ||
@@ -8,2 +9,5 @@ module.exports = function(locals) { | ||
const posts = locals.posts.sort(config.index_generator.order_by); | ||
sort(posts.data, (a, b) => (b.sticky || 0) - (a.sticky || 0)); | ||
const paginationDir = config.pagination_dir || 'page'; | ||
@@ -10,0 +14,0 @@ const path = config.index_generator.path || ''; |
{ | ||
"name": "hexo-generator-index", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Index generator for Hexo.", | ||
@@ -19,3 +19,3 @@ "main": "index", | ||
"engines": { | ||
"node": ">=8.6.0" | ||
"node": ">=10.13.0" | ||
}, | ||
@@ -34,11 +34,12 @@ "repository": "hexojs/hexo-generator-index", | ||
"chai": "^4.2.0", | ||
"eslint": "^6.0.1", | ||
"eslint-config-hexo": "^3.0.0", | ||
"hexo": "^3.0.0", | ||
"mocha": "^6.0.2", | ||
"nyc": "^14.1.1" | ||
"eslint": "^7.1.0", | ||
"eslint-config-hexo": "^4.1.0", | ||
"hexo": "^5.0.0", | ||
"mocha": "^8.0.1", | ||
"nyc": "^15.0.0" | ||
}, | ||
"dependencies": { | ||
"hexo-pagination": "1.0.0" | ||
"hexo-pagination": "1.0.0", | ||
"timsort": "^0.3.0" | ||
} | ||
} |
@@ -9,2 +9,4 @@ # hexo-generator-index | ||
It generates an archive of posts on your homepage, according to the `index` or `archive` layout of your theme. | ||
## Installation | ||
@@ -17,2 +19,3 @@ | ||
## Options | ||
Add or modify the following section to your root _config.yml file | ||
@@ -25,2 +28,3 @@ | ||
order_by: -date | ||
pagination_dir: page | ||
``` | ||
@@ -39,2 +43,18 @@ | ||
## 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 | ||
@@ -41,0 +61,0 @@ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
4779
25
61
0
2
+ Addedtimsort@^0.3.0
+ Addedtimsort@0.3.0(transitive)