惟愿言行合一,砥砺前行

0%

hexo 依赖

不小心把本地的博客文件全部删掉了,非常不幸的是,gitee 上 themes 文件夹中的 next 主题没有提交上去,导致主题全部要重新配置,累了毁灭吧。
(ps: 回退了一个 hexo 版本,不那么好看并且有非常非常多的 bug!!!!!!!!!!!!!啊之后再改吧毁灭吧!可以看 github 版本,那个看起来好歹没这么多 bug)

文章顺序

1
2
npm uninstall hexo-generator-index --save
npm install hexo-generator-index-pin-top --save

打开 /themes/next/layout/_macro/ 目录下的 post.swig 文件,在 <div class="post-meta"> 的第一个<span> 标签下,插入如下代码:

1
2
3
4
5
{% if post.top == 1 %}
<i class="fa fa-thumb-tack"></i>
<font color=2E8B57>TOP</font>
<span class="post-meta-divider">|</span>
{% endif %}

加密

1
npm install hexo-blog-encrypt --save

设置_config.yml,在encrypt下设置加密选项。

1
2
3
4
5
6
7
8
9
10
# 安全
encrypt: # hexo-blog-encrypt
enable: true
abstract: clock
message: need sth # 对密码的提示
tags: # 将tags中的文章加密并设置密码
- {name: 反思, password: 任意一个密码}
theme: up # 可以改成自己喜欢的主题,主题的选择可参考官方文档https://github.com/D0n9X1n/hexo-blog-encrypt/blob/master/ReadMe.zh.md#在-_configyml
wrong_pass_message: please stop trying # 密码错误时的提示
wrong_hash_message: sorry but it doesn't matter # 密码错误时的提示

主题设置

theme

设置next/_config.yml,theme 选 Gemini。

主题设置

修改source/_data/styles.styl

Gemini 暗夜主题。

1
2
3
4
5
6
7
8
9
10
11
custom_file_path:
#head: source/_data/head.swig
#header: source/_data/header.swig
sidebar: source/_data/sidebar.swig
#postMeta: source/_data/post-meta.swig
#postBodyEnd: source/_data/post-body-end.swig
#footer: source/_data/footer.swig
bodyEnd: source/_data/body-end.swig
#variable: source/_data/variables.styl
#mixin: source/_data/mixins.styl
style: source/_data/styles.styl

bodyEnd:

1
2
{# 代码压缩 #}
<script type="text/javascript" src="/js/fold_action.js"></script>

styles.styl:

鼠标指针自己画两个就好了。老抽象画大师了。我的头像也是自己画的了,因为之前那个头像放在主题文件夹里,删掉了,刚好最近在画画,随便换了一个,麻了。。。。。。

png 转 ico 的网站:PNG 转 ICO - 在线转换图标文件 (aconvert.com)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//鼠标指针设置
body {
cursor: url("/images/cursor.ico"),auto!important;
background-color:#282828;
}
//鼠标指针设置(改变)
a,span,btn,.copy-btn,.v[data-class=v] .vbtn,[data-v-0a6ec0b4],.spoiler-title,.post-meta time,.reward-container button,.sidebar-nav .sidebar-nav-active,.sidebar-nav li:hover,.spoiler .spoiler-title {
cursor: url("/images/cursor-click.ico"),pointer!important;
}
.header-inner,
.sidebar-inner,
.main-inner > .pagination,
.main-inner > .post-block,
.main-inner > .post-block:not(:first-child):not(.sub-menu)
{
border-radius: 20px 20px 20px 20px;
box-shadow: 8px 7px 2px 0 rgba(0,0,0,0.12), 7px 4px 1px -2px rgba(0,0,0,0.06), 0 1px 5px 0 rgba(0,0,0,0.12);
}

//文章内链接文本样式
.post-body li a,.post-body p a{
color: #E68F89;
border-bottom: none;
border-bottom: 1px solid #555;
&:hover {
color: #E68F89;
border-bottom: none;
border-bottom: 1px solid #fc6423;
}
}
//单行代码样式
code {
background: #252525;
border-radius: 4px;
color: #F2C7C4;
font-size: 15px
}
//版权声明样式
.post-copyright ul{
background: #1D1F21;
border-left:3px solid #E68F89;
}
//侧栏颜色
.sidebar-toc-active .sidebar-nav-toc,
.sidebar-overview-active .sidebar-nav-overview,
.post-toc .nav .active > a{
color: #E68F89;
border-bottom-color:#E68F89;
}
.sidebar-nav li:hover ,
.sidebar-toc-active .sidebar-nav-toc:hover
.sidebar-overview-active .sidebar-nav-overview:hover{
color: #FF7B71;
}
.post-toc-wrap .post-toc .nav .nav-item .nav-link:hover
.post-meta-item>a:hover{
color: #F2C7C4;
border-bottom-color:#F2C7C4;
}

// 代码折叠功能添加
.hider_title{
cursor: pointer;
color: #ef4a05;
}
.close:before{
content: "▼";
}
.open:before{
content: "▲";
}

.config.yml:

1
2
3
4
5
6
7
8
9
10
11
12
codeblock:
# Code Highlight theme
# Available values: normal | night | night eighties | night blue | night bright | solarized | solarized dark | galactic
# See: https://github.com/chriskempson/tomorrow-theme
highlight_theme: night
# Add copy button on codeblock
copy_button:
enable: true
# Show text copy result.
show_result: false
# Available values: default | flat | mac
style: mac

tag 颜色设置

1
2
3
4
5
6
7
8
# TagCloud settings for tags page.
tagcloud:
# All values below are same as default, change them by yourself.
min: 12 # Minimun font size in px
max: 30 # Maxium font size in px
start: "#555" # Start color (hex, rgba, hsla or color keywords)
end: "#ccc" # End color (hex, rgba, hsla or color keywords)
amount: 200 # Amount of tags, change it if you have more than 200 tags

打开 katex

打开 themes/next/_config.yml,找到katex,将enable改为true

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Math Formulas Render Support
math:
# Default (true) will load mathjax / katex script on demand.
# That is it only render those page which has `mathjax: true` in Front-matter.
# If you set it to false, it will load mathjax / katex srcipt EVERY PAGE.
per_page: true

# hexo-renderer-pandoc (or hexo-renderer-kramed) required for full MathJax support.
mathjax:
enable: false
# See: https://mhchem.github.io/MathJax-mhchem/
mhchem: false

# hexo-renderer-markdown-it-plus (or hexo-renderer-markdown-it with markdown-it-katex plugin) required for full Katex support.
katex:
enable: true
# See: https://github.com/KaTeX/KaTeX/tree/master/contrib/copy-tex
copy_tex: false

并且装好 hexo-renderer-markdown-it-plus。

1
npm install hexo-renderer-markdown-it-plus --save

还要修改让 katex-html 隐藏,否则会加载两次 katex。

1
2
3
4
5
6
7
.katex-html {
/* \newline is an empty block at top level, between .base elements */
> .newline {
display: none;
}
display: none;
}

注意,该修改需要 hexo clean 之后才能生效。

首页设置只显示摘要

参考:设置 hexo 首页只显示部分摘要(不显示全文)_hexo 博客只显示一部分-CSDN 博客

方法有两种:

  1. 在每篇文章间插入<!-- more -->,这样在首页只会显示这个标签之前的内容。
  2. 在每篇文章的开头加入description字段,这样在首页只会显示这个字段的内容。