目录结构
1 | ├── .github #git信息 |
为什么在custom.styl
修改CSS文件?
修改文章页宽
打开\themes\next\source\css\ _variables\base.styl
文件,找到以下字段并修改为合适的宽度:
1 | content-desktop-large = 1000px |
修改小型代码块颜色
修改\themes\next\source\css\ _variables\base.styl
文件,修改代码加入自定义颜色:
1 | $black-deep = #222 |
修改$code-background
和$code-foreground
的值
1 | // Code & Code Blocks // 用``围出的代码块 // -------------------------------------------------- |
添加文章结束标记
同样在themes/next/layout/_macro/post.swig
中,在 wechat-subscriber.swig
之前添加如下代码:
1 | <div style="text-align:center;color: #ccc;font-size:14px;">---------------- The End ----------------</div> |
把侧边栏头像变成圆形,并且鼠标停留在上面发生旋转效果
修改themes\next\source\css\_common\components\sidebar\sidebar-author.styl
:
1 | .site-author-image { |
修改链接文字样式
打开themes\next\source\css\_common\components\post\post.styl
添加以下代码,给链接添加颜色:
1 | .post-body p a{ |
为next主题的主页文章添加阴影效果
打开themes/next/source/css/_custom/custom.styl
文件添加:
1 | .post { |
为next主题添加nest背景特效
背景几何线条是采用的nest
效果,一个基于html5 canvas
绘制的网页背景效果,非常赞!来自github的开源项目canvas-nest
特性
- 不依赖任何框架或者内库,比如不依赖
- 非常小,只有1.66kb
- 非常容易实现,配置简单,即使不是web的开发者,也能简单搞定
配置选项
- color: 线条颜色, 默认:
'0,0,0'
;三个数字分别为(R,G,B),注意用,分割 - opacity: 线条透明度(0~1), 默认:
0.5
- count: 线条的总数量, 默认:
150
- zIndex: 背景的z-index属性,css属性用于控制所在层的位置, 默认:
-1
不足:CPU占用过高
修改_layout.swig
打开next/layout/_layout.swig
在</body>
之前添加如下代码
可参考官方文档:Canvas-Nest
1 | {% if theme.canvas_nest %} |
修改主题配置文件
打开/next/_config.yml
,添加如下代码
1 | # -------------------------------------------------------------- |
运行hexo clean
和 hero g -d
之后就可以在网页上看到效果了。
隐藏网页底部powered by hexo/强力驱动
打开hexo/themes/next/layout/_partials/footer.swig
找到下面这段代码,用第一行和最后一行注释掉即可
1 | <!-- |
侧栏加入已运行时间
themes/next/layout/_custom
中添加sidebar.swig
文件:
1 | <div id="days"></div> |
在themes/next/layout/_macro/sidebar.swig
中的</section>
之前添加:
1 | {% include '../_custom/sidebar.swig' %} |
设置时间样式:
1 | // 自定义的侧栏时间样式 |
更改tagcloud为彩色
themes/next/layout/page.swig
找到tagcloud并替换
:
1 | {{ tagcloud({min_font: 13, max_font: 31, amount: 1000, color: true, start_color: '#9733EE', end_color: '#FF512F'}) }} |
设置动态title
themes/next/source/js/src
下创建dytitle.js
:
1 | var OriginTitile = document.title; |
修改themes/next/layout/layout.swing
,在 </body>
之前添加:
1 | <script type="text/javascript" src="/js/src/dytitle.js"></script> |
修改文章底部带#的标签
修改模板/themes/next/layout/_macro/post.swig
,搜索 rel="tag">#
,将 # 换成<i class="fa fa-tag"></i>
文字样式
先在themes/next/source/css/_custom/custom.styl
中添加以下样式:
1 | // 下载样式 |
用法如下:
1 | <span id="inline-blue">站点配置文件</span>, |
站点配置文件,主题配置文件
1 | <p id="div-border-left-red">左边红色</p> |
左边红色
上边蓝色
在文档中增加图标
采用的是Font Awesome的图标。
给文档加密
打开themes->next->layout->_partials->head.swig
文件,在开头的四个meta
之后插入以下代码:1
2
3
4
5
6
7
8
9
10
11
12
13
14<script>
(function () {
if ('{{ page.password }}') {
if (prompt('请输入文章密码') !== '{{ page.password }}') {
alert('密码错误!');
if (history.length === 1) {
location.replace("http://xxxxxxx.xxx"); // 这里替换成你的首页
} else {
history.back();
}
}
}
})();
</script>
然后在MD文章头文件中加入
password:
password
侧边栏推荐阅读
打开主题配置文件</p>修改成这样就行了(links里面写你想要推荐的链接):1
2
3
4
5
6
7
8
9
10
11# Blogrolls
links_title: 推荐阅读
#links_layout: block
links_layout: inline
links:
优设: http://www.uisdc.com/
张鑫旭: http://www.zhangxinxu.com/
Web前端导航: http://www.alloyteam.com/nav/
前端书籍资料: http://www.36zhen.com/t?id=3448
百度前端技术学院: http://ife.baidu.com/
google前端开发基础: http://wf.uisdc.com/cn/
新增评论系统
去除评论系统下方的powered by valine
打开/next/layout/_third-party/comments/valine.swig
文件,1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18new Valine({
el: '#comments' ,
verify: {{ theme.valine.verify }},
notify: {{ theme.valine.notify }},
appId: '{{ theme.valine.appid }}',
appKey: '{{ theme.valine.appkey }}',
placeholder: '{{ theme.valine.placeholder }}',
avatar:'{{ theme.valine.avatar }}',
guest_info:guest,
pageSize:'{{ theme.valine.pageSize }}' || 10,
});
//新增以下代码即可,可以移除.info下所有子节点。
var infoEle = document.querySelector('#comments .info');
if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0){
infoEle.childNodes.forEach(function(item) {
item.parentNode.removeChild(item);
});
}