进入网页,F12进入调试模式(本次以谷歌浏览器为例,注意点击箭头指向的小箭头)。
通过观察可以发现整个头部是包裹在一个header里而且大家把鼠标放上去也可以很清楚的看到标签包裹的是哪些部分,那么通过开发工具可以看到右边对应的是生成在这个标签上class里的一些样式设置。
点击需要自己DIY的模块,我们可以暂时直接在更改对应数值进行更改样式,直到得到自己满意的效果,最后才去next里的一些文件进行部分的添加和修改来达到我们的目的。
注意箭头的几个点即可,改好之后记得copy下代码。
修改代码:找到你主题文件夹里的对应位置D:\hexo\blog\themes\next\source\css
里面有5个文件夹和一个styl文件,
main.styl主要用于打包CSS代码输出成CSS样式的main.css文件。
注意:本人不提倡去修改除了_custom下的其他4个文件里的源代码,可能后面出问题不好还原。
注释使用 // 而不是 # 。
打开blog\themes\next\source\css\_custom\custom.styl,添加
// Custom styles.
//首页文章阴影样式
.post {
margin-top: 60px;
margin-bottom: 60px;
padding: 25px;
-webkit-box-shadow: 0 0 14px rgba(202, 203, 203, .5);
-moz-box-shadow: 0 0 14px rgba(202, 203, 204, .5);
}
在主题配置文件,搜索下图关键字。在注释对应网址注册账号,左侧Set up & customize
获取ChatraID以及进行样式定制
打开主题配置文件,在对应网站注册。设置,创建应用,应用名为 Counter(不可更改),并获取key,安全中心填写自己的域名。
安全中心:web安全域名添加自己域名。注意前缀https://
注意配置完的网页菜单栏每个系统都加了评论,要选择删除需要到对应的文件夹里面的 index.md 都添加comments: false
语句。
主题配置文件,搜索Rating ,根据上方提示注册账号获取key。
需要注意的是:
经过上面的配置,默认最下面只会显示 5 颗小星星,简洁但不明了,怎么加上文字说明呢?
首先打开文件(~/blog/themes/next/layout/_macro/post.swig):
{% if theme.rating.enable %}
{% endif %}
打开文件(~/blog/themes/next/layout/_custom/sidebar.swig),加入以下代码。
如果感觉上下留白太多,咋整?浏览器 F12 找元素,调成自己喜欢的值,然后 Copy 到 custom.styl 即可.
首先要在主题配置文件中配置好,比如我把头像avatar.png
放在~/blog/source/uploads/
下。
然后编辑文件(~/blog/themes/next/layout/_macro/sidebar.swig),搜索site-author-image,添加两句代码即可。
这里注意图片格式需要保持一致。
修改 /themes/next/layout/ _macro/post.swig ,在 if is_index 与 if post.description and theme.excerpt_description 之间添加以下代码(大约在283行)。
{% if post.images %}
{% endif %}
在/themes/next/source/js/src
下新建文件clicklove.js
,接着把该链接下的代码拷贝粘贴到clicklove.js
文件中。
!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
修改_layout.swig,在\themes\next\layout\_layout.swig
文件末尾添加:
实现效果
在next\source\js\src
文件夹下创建crash_cheat.js
,添加代码
var OriginTitle = document.title;
var titleTime;
document.addEventListener('visibilitychange', function () {
if (document.hidden) {
$('[rel="icon"]').attr('href', "/img/TEP.ico");
document.title = '?你应该是一场梦';
clearTimeout(titleTime);
}
else {
$('[rel="icon"]').attr('href', "/favicon.ico");
document.title = '☀我应该是一阵风' + OriginTitle;
titleTime = setTimeout(function () {
document.title = OriginTitle;
}, 2000);
}
});
在next\layout\_layout.swig
文件中,添加引用(注:在swig末尾添加):
参考文章:Yang ZiHao、易 象 辞、asdfv1929