ghost 添加畅言评论系统

1.首先在畅言注册并认证。没有通过域名认证则只能使用15天。

2.认证通过之后就可以获取评论插件的代码。

<!--PC版-->
<div id="SOHUCS" sid="请将此处替换为配置SourceID的语句"></div>
<script charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/changyan.js" ></script>
<script type="text/javascript">
window.changyan.api.config({
appid: '*****',
conf: '****'
});
</script>

3.在 ghost 主题的 post.hbs 中安装代码。

登录畅言云评论后台,安装云评论-通用代码安装-自适应安装代码

<!--PC和WAP自适应版-->
<div id="SOHUCS" sid="请将此处替换为配置SourceID的语句" ></div> 
<script type="text/javascript"> 
(function(){ 
var appid = 'cys6dOPAU'; 
var conf = 'prod_e271b7ad175bc44bbae492eb77e06e8a'; 
var width = window.innerWidth || document.documentElement.clientWidth; 
if (width < 960) {
var head = document.getElementsByTagName('head')[0]||document.head||document.documentElement;
var script = document.createElement('script');
script.type = 'text/javascript';
script.charset = 'utf-8';
script.id = 'changyan_mobile_js';
script.src = 'https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf;
head.appendChild(script);
} else { var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})}); } })(); </script>

sourceid 可以从 {{comment_id}} 或 {{url absolute="true"}} 中选一个

4.重启 ghost,刷新网站,就可以在文章中找到相应的评论框(注意:因为需要域名验证,本地是不能够看到评论插件的)。


Share Tweet Send
0 Comments
Loading...
You've successfully subscribed to 隔窗听雨
Great! Next, complete checkout for full access to 隔窗听雨
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.
豫ICP备19045256号-1