Hexo搭建的博客无了~~~

然后现在重新搭建一下,记录一下改的东西
需要安装Nodejs
我目前使用的安装器是yarn,这个是可以换的

安装Hexo+Butterfly

Hexo文档: https://hexo.io/
Butterfly文档: https://butterfly.js.org/

安装

1
npm install -g hexo-cli

初始化

1
2
hexo init
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly

使用主题

修改_config.yml文件

1
theme: butterfly

pug文件错误

1
yarn add hexo-renderer-pug hexo-renderer-stylus

更多配置看上面的文档链接

一些基础配置

不要显示顶部图,直接配置disable_top_img: true

首先就是帖子链接的问题

安装: https://github.com/ohroy/hexo-abbrlink

1
yarn add hexo-abbrlink

修改_config.yml文件,例子如下:

1
2
3
4
5
6
7
8
9
10
11
# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: https://blog.greglee.cn
permalink: posts/:abbrlink/
abbr.link:
alg: crc32 # 算法 (crc16/crc32)
rep: hex # 进制 (dec/hex)
permalink_defaults:
pretty_urls:
trailing_index: false # Set to false to remove trailing 'index.html' from permalinks
trailing_html: false # Set to false to remove trailing '.html' from permalinks

字数统计

1
yarn add hexo-wordcount

F12提示

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
// F12提示
(function () {
'use strict';

var MESSAGE_TEXT = '已打开开发者模式,请谨记GPL协议!';
var SIZE_THRESHOLD = 160; // outer - inner 超过此值,认为 DevTools 已打开
var CHECK_INTERVAL = 500; // ms
var lastState = false;

// 显示 Snackbar 提示
function showTip() {
if (typeof Snackbar !== 'undefined' && Snackbar.show) {
Snackbar.show({
text: MESSAGE_TEXT,
pos: 'top-right',
showAction: false,
duration: 4000
});
} else {
// 兜底:如果 Snackbar 没有加载
alert(MESSAGE_TEXT);
}
}

// 快捷键监听
function keyListener(e) {
var isF12 = (e.key && e.key === 'F12') || e.keyCode === 123;
var isCtrlShiftI = (e.ctrlKey || e.metaKey) && e.shiftKey && (e.key === 'I' || e.key === 'i');
var isCtrlShiftJ = (e.ctrlKey || e.metaKey) && e.shiftKey && (e.key === 'J' || e.key === 'j');
if (isF12 || isCtrlShiftI || isCtrlShiftJ) {
setTimeout(showTip, 50);
}
}

// 窗口尺寸差检测
function isDevToolsOpenBySize() {
var widthDiff = Math.abs(window.outerWidth - window.innerWidth);
var heightDiff = Math.abs(window.outerHeight - window.innerHeight);
return widthDiff > SIZE_THRESHOLD || heightDiff > SIZE_THRESHOLD;
}

function periodicCheck() {
var open = isDevToolsOpenBySize();
if (open && !lastState) {
showTip();
}
lastState = open;
}

// 初始化
function init() {
if (window.top !== window.self) return;
window.addEventListener('keydown', keyListener, false);
window.addEventListener('resize', function () {
setTimeout(periodicCheck, 50);
}, false);
setInterval(periodicCheck, CHECK_INTERVAL);
}

init();
})();