Next 文末添加 The End

添加一个小细节,让自己写的文章显得更精致些,我们这里实现一个功能 — 为每一篇文章末尾添加 The End 来标识文章内容的结束。

加个需求

为每一篇文章末尾添加结束语!!!

修改主题配置文件

  • _config.next.yml
1
2
3
4
5
6
7
8
9
10
11
custom_file_path:
# head: source/_data/head.njk
#header: source/_data/header.njk
#sidebar: source/_data/sidebar.njk
#postMeta: source/_data/post-meta.njk
postBodyEnd: source/_data/post-body-end.njk ## 取消注释,添加下方代码
#footer: source/_data/footer.njk
bodyEnd: source/_data/body-end.njk
variable: source/_data/variables.styl
#mixin: source/_data/mixins.styl
style: source/_data/styles.styl

前面我们有提到 custom_file_path 标签是 Next 主题为用户专门留的自定义文件目录,方便用户添加各种自定义样式。这里我们需要对每一篇文章末尾添加样式,所以需要新建 source/_data/post-body-end.njk ;如有,请直接添加下面的样式。

添加样式

  • source/_data/post-body-end.njk
1
2
3
4
5
<div>
{% if not is_index %}
<div style="text-align:center;color: #ccc;font-size:24px; padding-top: 10px;">--------------------------------------- The End --------------------------------------- </div>
{% endif %}
</div>

hexo clean && hexo server 清除缓存之后重新启动服务。

参考链接

[1] hexo的next主题个性化教程:打造炫酷网站 | Moorez (shenzekun.cn)