$ pwd
/e/GitHup_Data/Hexo_Blog
$ mkdir scripts
$ cat scripts/AddTail.js
// Filename: AddTail.js
// Author: Colin
// Date: 2016/06/02
// Based on the script by KUANG Qi: http://kuangqi.me/tricks/append-a-copyright-info-after-every-post/
// Add a tail to every post from tail.md
// Great for adding copyright info
var fs = require('fs');
hexo.extend.filter.register('before_post_render', function(data){
if(data.copyright == false) return data;
// Add seperate line
data.content += '\n___\n';
// Try to read tail.md
try {
var file_content = fs.readFileSync('tail.md');
if(file_content && data.content.length > 50)
{
data.content += file_content;
}
} catch (err) {
if (err.code !== 'ENOENT') throw err;
// No process for ENOENT error
}
// 添加具体文章链接, 不需要去掉即可
var permalink = '\n本文出自"Jack Wang Blog":' + data.permalink;
data.content += permalink;
return data;
});
$ cat tail.md
本作品采用[知识共享署名 2.5 中国大陆许可协议](https://creativecommons.org/licenses/by/2.5/cn/)进行许可,欢迎转载,但转载请注明来自[Jack Wang Blog](https://yfshare.github.io),并保持转载后文章内容的完整。本人保留所有版权相关权利。
$ hexo clean
$ hexo g
$ hexo deploy