您的位置:首页 > 其它

Hexo添加RSS和评论插件

2016-03-20 23:52 232 查看
一、添加RSS

我的主题配置文件已含有rss: /atom.xml

因此我就直接安装部署了。

根目录下的配置信息:在# Extensions中添加,已经有的就免了。

plugins: hexo-generator-feed

打开Terminal(终端)输入:运行

npm install hero-generator-feed

重新部署:

hexo clean

hexo d -

二、开启评论

1、首先,注册多说,并在根目录下的配置文件添加shot_name,这里是duoshuo_shortname

short name指你在注册多说时二级域名里你自己输入的那部分,不包括htpp://和.duoshuo.com。

这里有人说在主题配置信息里配置duoshuo_shortname,但是我的始终搞不定,

我曾怀疑是不是data-thread-key等三个参数的问题,然后将page.path改为post.path,

仍然不行,只能慢慢试验了。

2、若使用默认主题landscape,则进入themes\landscape\layout\_partial\articles.ejs中,

将这段div中的disqus_shortname统统改为duoshuo_shortname,有的人没有这段,按实际情况来。

</div>

<footer class="article-footer">

<a data-url="<%- post.permalink %>" data-id="<%= post._id %>" class="article-share-link"><%= __('share') %></a>

<% if (post.comments && config.duoshuo_shortname){ %>

<a href="<%- post.permalink %>#duoshuo_thread" class="article-comment-link"><%= __('comment') %></a>

<% } %>

<%- partial('post/tag') %>

</footer>

</div>

3、网上大多数的都是说的这段代码替换:替换<section>到</section>之间的部分。

<% if (!index && post.comments && config.disqus_shortname){ %>

<section id="comments">

<div id="disqus_thread">

<noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>

</div>

</section>

<% } %>

替换为:

<% if (!index && post.comments && config.duoshuo_shortname){ %>

<section id="comments">

<!-- 多说评论框 start -->

<div class="ds-thread" data-thread-key="<%= post.path %>" data-title="<%= page.title %>" data-url="<%= page.permalink %>"></div>

<!-- 多说评论框 end -->

<!-- 多说公共JS代码 start (一个网页只需插入一次) -->

<script type="text/javascript">

var duoshuoQuery = {short_name:'<%= config.duoshuo_shortname %>'};

(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 -->

</section>

<% } %>

这里需要注意的是data-thread-key等三个参数,对小白来说并不知道如何设置:

我的设置如下:大多数网上的也都设的这个。

data-thread-key:<%= page.path %>

data-title:<%= page.title %>

data-url(稳定版没有这个,开发版有这个参数):<%= page.permalink %>

4、重新部署

hexo clean

hexo d -

搞定。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: