想添加奇怪的东西但害怕被简单发现?这个插件可以帮你优雅隐藏
隐藏后 没有置顶功能? 没关系,改配置
在博客目录下执行以下代码,安装hexo-generator-index2 插件,并卸载原来的主页插件(若不卸载会有冲突)
npm install hexo-generator-index2 --save
npm uninstall hexo-generator-index --save
打开博客根目录下_config.yml
添加下面代码,过滤分类或者标签为hide
的文章
# index2 generator是否包含官方的hexo-generator-index,默认true(包含)
index2_include_index: true
index2_generator:
per_page: 8 #每页显示的文章数
order_by: -date #
exclude:
- tag hide # 不包含标签为hide的文章
- category hide # 不包含分类为hide的文章
打开博客根目录下的 node_modules/hexo-generator-index2/lib/generator2.js
文件
在var posts = locals.posts.sort(generator.order_by);
下添加以下代码
posts.data = posts.data.sort(function(a, b) {
if(a.top && b.top) { // 两篇文章top都有定义
if(a.top == b.top) return b.date - a.date; // 若top值一样则按照文章日期降序排
else return b.top - a.top; // 否则按照top值降序排
}
else if(a.top && !b.top) { // 以下是只有一篇文章top有定义,那么将有top的排在前面(这里用异或操作居然不行233)
return -1;
}
else if(!a.top && b.top) {
return 1;
}
else return b.date - a.date; // 都没定义按照文章日期降序排
});
文章隐藏
在文章front-matter
中,标签或分类改为hide即可
tags: hide
或
categories: hide
----
置顶功能
在文章front-matter
中添加 top: 数字
即可置顶
在博客首页由大到小排列
参考
hexo首页优雅的隐藏部分文章_100斤的博客-CSDN博客
https://blog.csdn.net/qq_15602635/article/details/83479980解决Hexo博客文章置顶问题 | Zhiwei's Blog
https://zhwhong.cn/2017/03/23/deal-with-hexo-article-top-problem/
版权属于:hshx123
本站采用 “知识共享署名-非商业性使用-相同方式共享4.0中国大陆许可协议” 许可。 您可转载本站文章,请以超链接形式标明本文原始出处、作者信息以及版权声明。下方评论必须填写真实邮箱(如:QQ邮箱格式: QQ号@qq.com )
嗯?图片丢了