Hexo NexT 主题配置
本文记录如何使用Hexo中的NexT主题来配置和美化自己的博客页面。
好用插件
评论系统
giscus
安装hexo-next-giscus。
配置参考hexo-next & giscus 评论测试,Hexo 评论系统(Giscus)。
文章加密
安装hexo-blog-encrypt。
配置参考NEXT文章加密 ,为hexo文章加密。
书单页、影单页
安装hexo-douban,嵌入豆瓣个人主页。
注意:在hexo-theme-next主题中,需要将_config.next.yml中的pjax设置为false,否则书单页面无法正常渲染。
文章隐藏
hexo-hide-posts
我的 _config.yml 配置如下:
1 | hide_posts: |
配置后首页sidebar日志数量显示的不包含隐藏的,archive页面日志数量和按年统计数量不匹配(都是不包含隐藏的)。
修改代码如下:
node_modules\hexo-theme-next\layout\_partials\sidebar\site-overview.njk和
node_modules\hexo-theme-next\layout\archive.njk中:
site.posts.length 修改为
(site.all_posts or site.posts).length
node_modules\hexo-theme-next\layout\_macro\post-collapse.njk中将
post_count(year) 函数替换为
all_posts_count_by_year(year),
并在在站点根目录新建文件:scripts/all-posts-helper.js,添加内容:
1 | hexo.extend.helper.register('all_posts_count_by_year', function (year) { |
后续更新NexT主题时可能会覆盖修改,需将其手动改回来。(目前没时间考虑 universality)