hexo个人博客搭建

优化

开启本地搜索

1
npm install hexo-generator-searchdb --save

添加点击爱心效果

1、创建js文件
/themes/next/source/js/src下新建文件 clicklove.js ,接着把该链接下的代码拷贝粘贴到 clicklove.js 文件中

1
!function(e,t,a){function n(){c(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"),o(),r()}function r(){for(var e=0;e<d.length;e++)d[e].alpha<=0?(t.body.removeChild(d[e].el),d.splice(e,1)):(d[e].y--,d[e].scale+=.004,d[e].alpha-=.013,d[e].el.style.cssText="left:"+d[e].x+"px;top:"+d[e].y+"px;opacity:"+d[e].alpha+";transform:scale("+d[e].scale+","+d[e].scale+") rotate(45deg);background:"+d[e].color+";z-index:99999");requestAnimationFrame(r)}function o(){var t="function"==typeof e.onclick&&e.onclick;e.onclick=function(e){t&&t(),i(e)}}function i(e){var a=t.createElement("div");a.className="heart",d.push({el:a,x:e.clientX-5,y:e.clientY-5,scale:1,alpha:1,color:s()}),t.body.appendChild(a)}function c(e){var a=t.createElement("style");a.type="text/css";try{a.appendChild(t.createTextNode(e))}catch(t){a.styleSheet.cssText=e}t.getElementsByTagName("head")[0].appendChild(a)}function s(){return"rgb("+~~(255*Math.random())+","+~~(255*Math.random())+","+~~(255*Math.random())+")"}var d=[];e.requestAnimationFrame=function(){return e.requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)}}(),n()}(window,document);

2、修改_layout.swig
\themes\next\layout\_layout.swig文件末尾添加:

1
2
<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/src/clicklove.js"></script>

优化文章内链接文本样式

next\source\css\_common\components\post\post.styl在末尾添加如下css样式

1
2
3
4
5
6
7
8
9
10
11
// 文章内链接文本样式
.post-body p a{
color: #0593d3;
border-bottom: none;
border-bottom: 1px solid #0593d3;
&:hover {
color: #fc6423;
border-bottom: none;
border-bottom: 1px solid #fc6423;
}
}

显示文章的字数与阅读时长

1
npm install hexo-symbols-count-time --save

发布到github

1
2
3
4
deploy:
type: git
repo: [email protected]:zwcy/blog.git
branch: master

问题

java-code-tip

hexo d后 ERROR Deployer not found: git

安装hexo-deployer-git插件

1
npm install --save hexo-deployer-git

背景动画Canvas_nest: true设置无效的解决方案

下载canvas-nest插件

1
2
3
4
5
6
7
#进入next主题
cd themes/next

# git clone canvas-nest
git clone https://github.com/theme-next/theme-next-canvas-nest source/lib/canvas-nest

# 进入 thems/next/_config.yml文件下修改 canvas_nest: true

git push github失败,提示:SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443

登录一下github网页版

:year 年份
:category 分类。如果文章没有分类,则是 default_category 配置信息
:hash SHA1 hash of filename (same as :title) and date (12-hexadecimal)
post_title 文章标题
:name 文件名称