Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能否支持disqus? #4

Open
CodeJuan opened this issue Jun 19, 2015 · 6 comments
Open

能否支持disqus? #4

CodeJuan opened this issue Jun 19, 2015 · 6 comments

Comments

@CodeJuan
Copy link

感谢楼主分享,好人一生平安 👍 👍 👍 👍
有个小小的问题,能否支持disqus?毕竟还有不少同僚用的是disqus呢。
我正在学前端,尝试自己实现这个功能,不知能否搞定
😃

@wuhaoworld
Copy link
Owner

这周末看一下 disqus 的文档,新开个分支试一下

@CodeJuan
Copy link
Author

{% if site.disqus %}
<div class="comments">
    <div id="disqus_thread"></div>
    <script type="text/javascript">

        var disqus_shortname = '{{ site.disqus }}'; 
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
{% endif %}

这是我在jekyll上看到的,不过还不知道怎么弄。
楼主可以参考一下

@zhaiyiting
Copy link

直接用github issue的comment可否?

@izuolan
Copy link

izuolan commented Jun 20, 2015

希望直接用github issue的comment,反正都用issues了,不知道怎么实现呢?

@wuhaoworld
Copy link
Owner

如果评论使用 github issues 的评论,获取评论还好说,提交、删除评论、回复提醒、登陆认证等功能一方面会大大增加程序本身的复杂度,另一方面对于想评论的用户需要额外的跳转和认证步骤,用户体验不友好,所以我还是倾向于用第三方评论来实现此功能。

@wuhaoworld
Copy link
Owner

Disqus 提供了动态加载评论的方法:
https://help.disqus.com/customer/portal/articles/472107-using-disqus-on-ajax-sites
但是官方提供的通用代码无法修改(不知道为啥,修改加载方式就会报错),必须等通用代码加载完毕后再调用动态加载方法才行,不修改通用代码的前提下管理 js 加载顺序,我还不知道怎么处理才好。希望有兴趣的童鞋可以提交 pull request 😄

相对来说多说直接提供了非常简单的调用接口:http://dev.duoshuo.com/docs/50b344447f32d30066000147 实现起来简单的多。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants