Hexo 入门指南(七) - 评论 & 分享

简介: Hexo 入门指南(七) - 评论 & 分享

评论


hexo默认集成了disqus,但是在天朝明显多说更受欢迎一点。


首先到多说官网去注册一个账号。然后点击进入添加站点页面,填写所有信息。注意,多说域名的前缀就是站点的短网址,下面要用到,这里假设为short_name


在_config.yml中添加多说的配置:

duoshuo_shortname: short_name


修改themes\<theme_name>\layout\_partial\article.ejs,把第38行到41行的如下代码:

<% 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.layout %>-<%= post.slug %>" data-title="<%= post.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>
<% } %>



之后,找到第27到29行:

<% if (post.comments && config.disqus_shortname){ %>
  <a href="<%- post.permalink %>#disqus_thread" class="article-comment-link">Comments</a>
<% } %>


替换成:

<% if (post.comments && config.duoshuo_shortname){ %>
  <a href="<%- url_for(post.path) %>#comments" class="article-comment-link">留言</a>
<% } %>



分享


hexo默认提供的那四个在国内也被墙了。这里替换成百度一键分享。


找到themes\landscape\layout\_partialarticle.ejs26行:

<a data-url="<%- post.permalink %>" data-id="<%= post._id %>" class="article-share-link">分享</a>



替换成:

<a data-url="<%- post.permalink %>" data-id="<%= post._id %>" class="article-share-link bdsharebuttonbox" data-cmd="more">分享</a>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"1","bdMiniList":false,"bdPic":"","bdStyle":"2","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>

之后打开themes\landscape\source\js\script.js,35~86行全部注释掉。


相关文章
|
小程序
微信小程序:rich-text 富文本中图片自适应
微信小程序:rich-text 富文本中图片自适应
454 0
|
9月前
|
JSON JavaScript 数据格式
使用pnpm搭建monorepo开发环境
使用pnpm搭建monorepo开发环境
390 0
|
6月前
|
机器学习/深度学习 算法
【机器学习】梯度消失和梯度爆炸的原因分析、表现及解决方案
本文分析了深度神经网络中梯度消失和梯度爆炸的原因、表现形式及解决方案,包括梯度不稳定的根本原因以及如何通过网络结构设计、激活函数选择和权重初始化等方法来解决这些问题。
719 0
|
JSON 算法 安全
【技术干货】JWT令牌的原理及应用
本文对微服务中使用的JWT(JSON Web Token)的原理:包括结构、签名验签、实际应用场景进行了详细说明
1761 1
|
8月前
|
JSON 前端开发 安全
写了几年代码,你将跨域问题弄明白了吗?
互联网发展至今,前端开发者经常面临跨域问题,这是因为浏览器的同源策略限制了不同源的网页之间的数据交互。当尝试从`http://127.0.0.1:14949`访问`http://localhost:3000`的资源时,浏览器会阻止这种请求,因为它缺少“Access-Control-Allow-Origin”响应头,这是CORS(跨域资源共享)机制的要求。
|
存储 机器学习/深度学习 算法
acm拿国奖的第二关:栈和队列
如上所述,队列应支持两种操作:入队和出队。入队会向队列追加一个新元素,而出队会删除第一个元素。 所以我们需要一个索引来指出起点。
113 0
acm拿国奖的第二关:栈和队列
|
运维 API 虚拟化
分享OpenStack API使用套路
分享OpenStack API使用套路
164 0
|
Java 应用服务中间件 nginx
|
9月前
|
存储 数据可视化 Shell
18 个 Jupyter Notebook 小技巧,帮助你快速腾飞
18 个 Jupyter Notebook 小技巧,帮助你快速腾飞
118 0
|
存储 Web App开发 缓存
渐进式Web应用(PWA)入门教程(下)
渐进式Web应用(PWA)入门教程(下)
264 0

热门文章

最新文章