默認主題 landscapejavascript
文件目錄,comments爲新建的
_config.yml layout -- _partial -- article.ejs |- comments -- disqus.ejs |- duoshuo.ejs |- youyan.ejs
註冊評論系統:php
Disqus 註冊 設置Shortnamejava
多說 不用註冊直接登陸(例如用百度帳號),設置域名app
友言 註冊,查看IDdom
1 修改主題配置文件 landscape/_config.yml 添加如下內容:async
# >>> Conments 評論系統 <<< # Chose ONE as your comment system and keep others disable. # 選一個做爲網站評論系統,其餘保持禁用。 disqus: on: true shortname: yourshortname # https://help.disqus.com/customer/en/portal/articles/466208-what-s-a-shortname- # It is unnecessary to enable disqus here if # you have set "disqus_shortname" in your site's "_config.yml" duoshuo: #on: true domain: yourdomain # 是否開啓多說評論,http://duoshuo.com/create-site/ # 使用上面網址登錄你的多說,而後建立站點,在 domain 中填入你設定的域名 # http://你的多說域名.duoshuo.com youyan: #on: true id: yourID # 是否開啓友言評論,http://www.uyan.cc/index.php # id 中填寫你的友言用戶數字ID,註冊後進入後臺管理便可查看 # 友言服務在 Web 環境下運行,普通本地環境沒法查看,請部署後在線上測試。 # >>> <<<
2 修改 article.ejs 添加:post
<% if (!index && post.comments){ %> <% if (theme.duoshuo.on) { %> <%- partial('comments/duoshuo', { key: post.path, title: post.title, url: config.url+url_for(post.path), }) %> <% } else if (theme.youyan.on) { %> <%- partial('comments/youyan') %> <% } else if (theme.disqus.on) { %> <%- partial('comments/disqus', { shortname: theme.disqus.shortname }) %> <% } else if (config.disqus_shortname) { %> <%- partial('comments/disqus', { shortname: config.disqus_shortname }) %> <% } %> <% } %>
3 在comments目錄下新建3個文件:disqus.ejs、duoshuo.ejs、youyuan.ejs測試
# disqus.ejs
<section id="comments"> <div id="disqus_thread"></div> <script type="text/javascript"> /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ var disqus_shortname = '<%= shortname%>'; // required: replace example with your forum shortname /* * * DON'T EDIT BELOW THIS LINE * * */ (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="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> </section>
# duoshuo.ejs
<div class="duoshuo" id="comments"> <!-- 多說評論框 start --> <div class="ds-thread" data-thread-key="<%=key%>" data-title="<%=title%>" data-url="<%=url%>"></div> <!-- 多說評論框 end --> <!-- 多說公共JS代碼 start (一個網頁只需插入一次) --> <script type="text/javascript"> var duoshuoQuery = {short_name:"<%=theme.duoshuo.domain%>"}; (function() { var ds = document.createElement('script'); ds.type = 'text/javascript';ds.async = true; ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js'; ds.charset = 'UTF-8'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ds); })(); </script> <!-- 多說公共JS代碼 end --> </div>
# youyuan.ejs
<section class="youyan" id="comments"> <div id="uyan_frame"></div> <script src="http://v2.uyan.cc/code/uyan.js?uid=<%= theme.youyan.id%>"></script> </section>
配置完成,能夠自由選擇使用一種評論系統了!效果以下:網站
對於maupassant主題,已經自帶了disqus、多說 評論系統,只須要在maupassant/_config.yml中開啓便可ui