在 jekyll 上使用 disqus
disqus 介紹
是一個可以讓網頁快速產生留言功能的服務,透過簡單的埋 code 的動作就可以搞定!
更是透過 github.io 建立靜態頁面使用者的福音! 到時候完成的效果會長得像文章下面的留言區
如何使用 disqus ?
1.在 md 檔
原本的設定區域多新增一個
comments: true
…
tags: [jekyll, disqus]
comments: true
…
2.去disqus 官網 註冊會員,照官網流程做的話程式應該會像下面這樣,只要把程式碼貼在要實現的 layout 上即可
# % if page.comments %
<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 = 'https://your-shortname.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>
# % endif %
結論
本篇只有簡單帶到怎麼用這服務,像是不同付費方案可以用更多延伸功能(有人留言時會寄信到信箱、設定 comment policy…等)