Hexo的hexo-theme-matery主题配置评论

0. 前言

之前写过一篇文章用Hexo搭建个人博客,介绍如何用Hexo搭建个人博客网站,使用了hexo-theme-matery主题,今天介绍一下这个主题下使用的评论插件。

1. 评论插件

matery主题集成了各种评论模块,例如 gitalkgitmentdisqusliverevalinewalineTwikooutteranc 等,今天要介绍的 utteranc 这种插件是集成在github种的评论插件,并且能够做到github邮箱通知。下面就来详细介绍一下utteranc如何配置

1.1 新建一个评论仓库

首先创建一个公开的评论仓库<自定义名称> !注意一定要公开,否则别人无法评论

1.2 安装utteranc

  • 进入utteranc,点击install
  • 选择刚刚创建的自定义评论仓库
  • repo输入自己刚刚新建的仓库
  • 其他按照自己的需要挑战,把最后生成的配置,copy 下来
ini 复制代码
<script src="https://utteranc.es/client.js"
        repo="ZBIGBEAR/sync_test"
        issue-term="pathname"
        theme="github-light"
        crossorigin="anonymous"
        async>
</script>

1.3 添加配置到matery主题

  • 修改matery主题的配置文件 themes/hexo-theme-matery/_config.yml ,开启utteranc功能
yaml 复制代码
# utteranc config, default disabled
# utteranc 评论模块的配置,默认为不激活
utteranc:
  enable: true
  • 修改博客文章 themes/hexo-theme-matery/layout/_partial/post-detail.ejs
scss 复制代码
<% if (theme.utteranc && theme.utteranc.enable) { %>
<%- partial('_partial/utteranc') %>
<% } %>

该处改动的目的是为了在所有博客文章中统一在底部加入一个评论模块,这个改动很关键、所放位置也很重要。

  • 新增一个文件 themes/hexo-theme-matery/layout/_partial/utteranc.ejs
ini 复制代码
<div class="card" data-aos="fade-up">
    <div id="utteranc-container" class="card-content">
        <script src="https://utteranc.es/client.js"
                repo="jijunhao/utterances"
                issue-term="pathname"
                theme="github-light"
                crossorigin="anonymous"
                async>
        </script>
    </div>
</div>

所有的留言都会出现在自定义评论仓库 issues 的,并且会每次给邮箱发消息。

  • 如果博客中还有单独的一个留言板模块,需要改 themes/hexo-theme-matery/layout/contact.ejs
scss 复制代码
<% if (theme.utteranc && theme.utteranc.enable) { %>
    <%- partial('_partial/utteranc') %>
<% } %>

最后重启hexo,就能在网页拥有评论功能了。

2. 参考

1\][用Hexo搭建个人博客](https://juejin.cn/post/7338651990476324903 "https://juejin.cn/post/7338651990476324903") \[2\][Hexo-Matery主题评论插件](https://link.juejin.cn?target=https%3A%2F%2Fwww.cnblogs.com%2Fjijunhao%2Fp%2F17235903.html "https://www.cnblogs.com/jijunhao/p/17235903.html")

相关推荐
烛阴44 分钟前
bignumber.js深度解析:驾驭任意精度计算的终极武器
前端·javascript·后端
服务端技术栈1 小时前
电商营销系统中的幂等性设计:从抽奖积分发放谈起
后端
你的人类朋友1 小时前
✍️Node.js CMS框架概述:Directus与Strapi详解
javascript·后端·node.js
面朝大海,春不暖,花不开2 小时前
自定义Spring Boot Starter的全面指南
java·spring boot·后端
钡铼技术ARM工业边缘计算机2 小时前
【成本降40%·性能翻倍】RK3588边缘控制器在安防联动系统的升级路径
后端
CryptoPP3 小时前
使用WebSocket实时获取印度股票数据源(无调用次数限制)实战
后端·python·websocket·网络协议·区块链
白宇横流学长3 小时前
基于SpringBoot实现的大创管理系统设计与实现【源码+文档】
java·spring boot·后端
草捏子4 小时前
状态机设计:比if-else优雅100倍的设计
后端
考虑考虑5 小时前
Springboot3.5.x结构化日志新属性
spring boot·后端·spring
涡能增压发动积5 小时前
一起来学 Langgraph [第三节]
后端