https://github.com/SukkaW/Dis...
使用 Disqus API 渲染评论列表,搭配 Disqus API 的反代可以实现在网络审查地区加载 Disqus 评论列表;支持自动检测访客的 Disqus 可用性自动选择加载原生 DISQUS(评论完整模式)和 DisqusJS 提供的评论基础模式。
简介
最早看到屈哥的 https://imququ.com 上看到了屈哥用 Disqus API 开发的「评论基础模式」供无法访问 Disqus 的访客查看评论和发表评论。同样使用 DISQUS 的我打算造一个类似的东西,于是就有了 DisqusJS。
特性
- 通过 Disqus API 渲染评论列表
- 判断访客是否能访问 DISQUS,自动选择不同模式
安装
下载 经过编译和压缩的 DisqusJS 相关文件,在需要安装 DisqusJS 的页面的 </head>
之前引入 DisqusJS 的 css、在 </body>
之前引入 Disqus 的 JS:
<link rel="stylesheet" href="disqusjs.css">
<script src="disqus.js"></script>
也可以使用 CDN 加载上述所需文件:
<!-- Unpkg -->
<link rel="stylesheet" href="https://unpkg.com/disqusjs@0.2.0/dist/disqusjs.css">
<script src="https://unpkg.com/disqusjs@0.2.0/dist/disqus.js"></script>
<!-- jsDelivr -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/disqusjs@0.2.0/dist/disqusjs.css">
<script src="https://cdn.jsdelivr.net/npm/disqusjs@0.2.0/dist/disqus.js"></script>
在需要显示评论的地方插入下述代码:
<div id="disqus_thread"></div>
<script>
var disqusjs = [];
disqusjs.config = {
shortname: '', // Your Disqus Shortname
identifier: '', // Your thread identifier
url: '', // Your page URL
api: '', // API Endpoint
apikey: '', // Your Disqus Application API Key
admin: '', // Disqus Moderator's Username
adminLabel: '' // Disqus Moderator Badge Text
};
</script>
Disqus API Application 的配置方法和 DisqusJS 配置参数说明请 阅读 DIsqusJS 的 README
为了便于使用静态博客、没有自己的 VPS 的个人博主使用,我搭建了一个 Disqus API 的反代,直接填在 api
中即可:https://disqus.skk.moe/disqus/
注意
- Disqus API 无法直接通过 AJAX 创建新评论(post),需要专门编写后端程序,所以 DisqusJS 暂时不支持「评论基础模式」下创建新评论。
- Disqus API 也不能使用 AJAX 初始化页面(创建新 thread),所以如果 DisquJS 检测到当前页面没有初始化,会提示是否切换到 Disqus 完整模式。
Author 作者
DisqusJS © Sukka, Released under the GPL-3.0 License.
Authored and maintained by Sukka with help from contributors (list).
Personal Website · Blog · GitHub @SukkaW · Telegram Channel @SukkaChannel
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。