萌约 MoeYork

一个普通的博客站点

0%

为 Hexo Next 主题集成 Cusdis 评论组件

因为本站为纯静态站点,为了让博客能评论,找了一个可以托管的评论服务 Cusdis

Next 主题默认不提供 Cusdis 的集成,所以简单搓了一个

配置修改

新建评论模板

  • 添加了中文语言(没写自适应倒是)
  • 参考 issue 修正了容器高度

source/_data/post-body-end.swig 中:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{% if theme.cusdis.enable %}
<hr />
<h3>评论</h3>
<div id="cusdis_thread"
data-host="{{ theme.cusdis.host }}"
data-app-id="{{ theme.cusdis.app_id }}"
data-page-id="{{ page.path }}"
data-page-url="{{ page.permalink }}"
data-page-title="{{ page.title }}"
style="display: flex; height: 24em;"
></div>
<script async defer src="https://cusdis.com/js/widget/lang/zh-cn.js"></script>
<script async defer src="https://cusdis.com/js/cusdis.es.js"></script>
{% endif %}

配置 Next 主题

cusdis 这部分对应评论模板中的内容

_config.next.yml 中:

1
2
3
4
5
6
custom_file_path:
postBodyEnd: source/_data/post-body-end.swig
cusdis:
enable: true
host: # 你的 cusdis 实例地址
app_id: # 你的 app_id

评论