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)];
最后重新生成下,就能展示分享功能了。
广大劳动人民智慧多,学到了!
参考链接: