Github+Jekyll新增評論支援
阿新 • • 發佈:2019-02-19
現在,可以非常方便的使用Jekyll+Guthub製作個人靜態網站。具體可以參考Github官方教程。
這裡介紹怎麼給文章、網頁新增評論支援。
選擇評論系統(commenting system)
主流的評論系統有Disqus, Facebook comment, IntenseDebate, Livefyre等。提供的功能和服務都大同小異,可以根據個人愛好選擇。這裡已IntenseDebate為例,主要原因是其它幾個要麼國內訪問不了,要麼訪問速度極慢,可以自己體驗。
先去IntenseDebate註冊一個賬號。
在Jekyll站點的_includes目錄下建立intense debate-comments.html檔案.
檔案內容如下。在{% if page.comments != false %}和{% endif %}之間就是IntenseDebate註冊完以後得到的腳步程式碼。如果使用其他評論系統,程式碼類似。
{% if page.comments != false %}
<script>
var idcomments_acct = 'xxxx50b9b39';
var idcomments_post_id = '{{ page.url }}';
var idcomments_post_url;
</script>
<span id="IDCommentsPostTitle" style="display:none"></span>
<script type='text/javascript' src='https://www.intensedebate.com/js/genericCommentWrapperV2.js'></script>
{% endif %}
在站點配置檔案中新增評論配置引數,方便靈活的enable/disable評論功能。
intensedebate_comments: true
在post.html檔案末尾後面新增程式碼引用intensedebate-comments.html來顯示評論框。
{% if site.intensedebate_comments %}{% include intensedebate-comments.html %}{% endif %}