Hexo笔记之版权信息和打赏

写之前备注:

站点根目录:就是你创建的blog文件夹目录,我的是daiyongtao.github.io。

主题目录:/theme/next。

在 Hexo 中有两份主要的配置文件,其名称都是 _config.yml。

其中,一份位于站点根目录下,主要包含 Hexo 本身的配置;

另一份位于主题目录下,这份配置由主题作者提供,主要用于配置主题相关的选项。

为了描述方便,在以下说明中,将前者称为 站点配置文件, 后者称为 主题配置文件。

底部配置

注:大部分配置其实next都已经帮我们集成好了,我们只需要打开就行。

底部版权信息:

第一步

主题目录:layout/_macro下,打开post.swig,找到 END POST BODY。
not is_index 表示不在body索引列表区域。在它下面有很多底部工具。
找到post-copyright

1
2
3
4
5
{% if theme.creative_commons.license and theme.creative_commons.post and not is_index %}
<div>
{% include '../_partials/post/post-copyright.swig' with { post: post } %}
</div>
{% endif %}

读代码可知:creative_commons下的license 和 post都有值的时候,才会创建版权信息div标签。

第二步

复制creative_commons,打开主题配置文件,找到creative_commons所在位置。

可以看到如下信息。

1
2
3
4
creative_commons:
license: by-nc-sa
sidebar: false
post: false

我们把post、sidebar打开,改成true。

post打开效果.png

sidebar打开效果.png

至于license许可证,大家可以根据提示:Available: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa | zero进行修改看结果。

license许可证.png

第三步

主题目录:source/css/_custom 下打开custom.styl。

添加如下代码:

1
2
3
4
5
6
7
8
// 版权信息
.post-copyright {
margin: 2em 0 0;
padding: 0.5em 1em;
border-left: 3px solid #ff1700;
background-color: #f9f9f9;
list-style: none;
}

我们在这里设置了post_copyright的样式。

第四步

最后,hexo g &&hexo server之后,就可以在本地查看效果了。

主题目录:layout/_partials/post下,存放着底部版权信息post-copyright.swig。

如果需要自定义底部版权信息,只需要在post-copyright.swig进行修改即可,网上有很多例子,在这就不多说了。

打赏:

打开主题配置文件,找到reward所在位置。

1
2
3
4
5
6
reward:
enable: true
comment: 坚持原创技术分享,您的支持将鼓励我继续创作!
wechatpay: /images/wechatpay.jpg
# alipay: /images/alipay.jpg
# bitcoin: /images/bitcoin.jpg

将enable打开,comment可以自己随便写,也可以按照我的模版。

下面是微信支付、支付宝支付、比特币三种支付方式,需要在主题目录下的source/images里添加你自己的二维码收款,就以上面的wechatpay.jpg等名字命名。我就只弄了微信的。

坚持原创技术分享,您的支持将鼓励我继续创作!