Theme NexT works best with JavaScript enabled

ShunNien's Blog

不積跬步,無以致千里;不積小流,無以成江海。

0%

Disqus 申請與設定

前言

一直以為我有記錄過這些,有朋友在詢問,才發現我居然沒紀錄過,乾脆趁現在重新寫一下好了。

註冊

註冊步驟很簡單,甚至可以使用 FaceBook、Twitter、Google Plus 帳號註冊,參照下圖吧

Sign Up

Sign up with

設定

註冊完成後,會顯示讓你選擇三個 channel,這個可以不用理它;直接進入 **
Add Disqus To Site**,之後簡單的設定好之後(shortname 要記好,不記得可以到設定去找)
Add Disqus To Site

Start Using Engage

這邊輸入您想要的 disqus url
Fill Info

會看到 Installation 選擇你自己的平台,這邊使用 js 方式(如果是其他平台,有些就會用到 shortname)
Universal Code

Disqus Universal Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<div id="disqus_thread"></div>
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables
*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');

s.src = '//disqussample01.disqus.com/embed.js';

s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>

其實嵌入如上所示,相當清楚,所以其實是可以將 js 這樣嵌入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

var disqus_shortname = your_short_name;

(function(){
if(document.querySelector('#disqus_thread')) {
var d = document, dsq = document.createElement('script');
dsq.async = true;
dsq.setAttribute('data-timestamp', +new Date());
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(d.head || d.body).appendChild(dsq);
}
}());


// 留言計數

(function(){
if(document.querySelector('#disqus_thread')) {
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/count.js';
(d.head || d.body).appendChild(dsq);
}
}());

最後附上 DISQUS 的連結

歡迎關注我的其它發布渠道