hexo-generator-indexed
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -8,4 +8,19 @@ 'use strict'; | ||
const posts = locals.posts.sort(config.index_generator.order_by); | ||
//添加按sticky排序,sticky在next主题中存在样式 | ||
posts.data = posts.data.sort(function(a, b) { | ||
posts.data = posts.data.filter(item => { | ||
if (item.hide) { | ||
return false; | ||
} | ||
if (config.hide_categories && item.categories.length) { | ||
for (var categorie of item.categories.data) { | ||
if (config.hide_categories.includes(categorie.name)) { | ||
return false; | ||
} | ||
} | ||
} | ||
return true; | ||
}); | ||
posts.length = posts.data.length; | ||
posts.data = posts.data.sort((a, b) => { | ||
if (a.sticky && b.sticky) { | ||
@@ -12,0 +27,0 @@ return (a.sticky == b.sticky) ? 0 : (b.sticky - a.sticky); |
{ | ||
"name": "hexo-generator-indexed", | ||
"version": "0.0.1", | ||
"description": "Index generator for Hexo.add pin function, fork from hexo-generator-index", | ||
"version": "0.0.2", | ||
"description": "Index generator for Hexo.", | ||
"main": "index", | ||
@@ -19,3 +19,3 @@ "scripts": { | ||
"type": "git", | ||
"url": "git+git@github.com:stevenjoezhang/hexo-generator-indexed.git" | ||
"url": "https://github.com/stevenjoezhang/hexo-generator-indexed.git" | ||
}, | ||
@@ -27,8 +27,9 @@ "homepage": "https://github.com/stevenjoezhang/hexo-generator-indexed", | ||
"index", | ||
"sticky", | ||
"home" | ||
"home", | ||
"sticky" | ||
], | ||
"author": "Mimi <zsq@zsq.im> (https://zhangshuqiao.org)", | ||
"maintainers": [ | ||
"rizon" | ||
"rizon", | ||
"Tommy Chen <tommy351@gmail.com> (http://zespia.tw)" | ||
], | ||
@@ -35,0 +36,0 @@ "license": "MIT", |
@@ -36,10 +36,8 @@ # hexo-generator-indexed | ||
## Feature | ||
## Feature & Usage | ||
### 增加置顶功能 | ||
USAGE | ||
在文章的Front Matter(即开头设置)中增加一个`sticky`参数用来置顶,数字越大越高 | ||
在文章的开头设置中增加一个`sticky`参数用来置顶,数字越大越高 | ||
```markdown | ||
@@ -52,6 +50,25 @@ --- | ||
采用sticky关键词是因为这个在next主题中已经定义了置顶样式,因此可以直接拿来使用 | ||
采用`sticky`关键词是因为这个在[NexT主题](https://github.com/theme-next/hexo-theme-next)中已经定义了置顶样式,因此可以直接拿来使用 | ||
### 增加隐藏功能 | ||
在文章的Front Matter中增加一个`hide`参数用来隐藏 | ||
```markdown | ||
--- | ||
title: example | ||
hide: true | ||
--- | ||
``` | ||
### 隐藏特定分类中的文章 | ||
在Hexo的`_config.yml`中可以设置隐藏某个分类下的文章,例如 | ||
```yml | ||
hide_categories: | ||
- categorie1 | ||
- categorie2 | ||
``` | ||
## License | ||
@@ -58,0 +75,0 @@ |
Sorry, the diff of this file is not supported yet
6867
56
77