Hexo NexT主题中添加百度分享功能--github填坑

Hexo NexT主题中添加百度分享功能–github填坑

今天给next主题添加了百度分享功能,在本地一切正常,但是当发布到github的时候,却不能正常显示—这就很烦,

于是我在网上搜索解决方法,如下:

_config.yml

因为next\layout_partials\share\baidushare.swig文件中代码显示:

{% if theme.baidushare.type === "button" %}
...
...
{% elseif theme.baidushare.type === "slide" %}
...

在配置百度分享功能时需指定其type,所以将主题配置_config.yml文件中关于baidushare部分的内容改为(其中type亦可以选择button):

baidushare:
  type: slide
  baidushare: true

download

_config.yml中提示:Warning: Baidu Share does not support https.
因为百度分享不支持在https上使用,所以一种解决方法便是,直接放文件到我们自己的目录下面。

访问链接: static文件夹
下载压缩包到本地,解压后,将static文件夹保存至themes\next\source目录下。

baidushare.swig

修改文件:themes\next\layout_partials\share\baidushare.swig
将文件 末尾 部分的代码进行修改:

.src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];

改为

.src='/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];

最后重新生成下,就能展示分享功能了。

广大劳动人民智慧多,学到了!

参考链接:

https://asdfv1929.github.io/2018/05/25/baidu-share/

全部评论

相关推荐

Just路人甲:MUC 是什么🤔,32不是 MCU 吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务