Blog源文件GitHub
Blog源文件GitHub
SanXiaoXing使用github上传自己的blog源文件
新环境
- 要在新环境继续在原有仓库基础上撸文章,此时通过
git clone
将博客源码拉到本地,然后安装、初始化hexo就能搞定:
1 | git clone ... |
hexo algolia
命令需要设置
HEXO_ALGOLIA_INDEXING_KEY`在
git bash
命令上执行:1
2
3export HEXO_ALGOLIA_INDEXING_KEY=""
./node_modules/.bin/hexo algolia配置pwa(我也不知道为啥会掉)
在
[Blogroot]\themes\butterfly\layout\includes\third-party\
目录下新建pwanotice.pug
文件,打开[Blogroot]\themes\butterfly\layout\includes\third-party\pwanotice.pug
,输入: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#app-refresh.app-refresh(style='position: fixed;top: -2.2rem;left: 0;right: 0;z-index: 99999;padding: 0 1rem;font-size: 15px;height: 2.2rem;transition: all 0.3s ease;')
.app-refresh-wrap(style=' display: flex;color: #fff;height: 100%;align-items: center;justify-content: center;')
label ✨ 有新文章啦! 👉
a(href='javascript:void(0)' onclick='location.reload()')
span(style='color: #fff;text-decoration: underline;cursor: pointer;') 🍗点击食用🍔
script.
if ('serviceWorker' in navigator) {
if (navigator.serviceWorker.controller) {
navigator.serviceWorker.addEventListener('controllerchange', function() {
showNotification()
})
}
window.addEventListener('load', function() {
navigator.serviceWorker.register('/sw.js')
})
}
function showNotification() {
if (GLOBAL_CONFIG.Snackbar) {
var snackbarBg =
document.documentElement.getAttribute('data-theme') === 'light' ?
GLOBAL_CONFIG.Snackbar.bgLight :
GLOBAL_CONFIG.Snackbar.bgDark
var snackbarPos = GLOBAL_CONFIG.Snackbar.position
Snackbar.show({
text: '✨ 有新文章啦! 👉',
backgroundColor: snackbarBg,
duration: 500000,
pos: snackbarPos,
actionText: '🍗点击食用🍔',
actionTextColor: '#fff',
onActionClick: function(e) {
location.reload()
},
})
} else {
var showBg =
document.documentElement.getAttribute('data-theme') === 'light' ?
'#3b70fc' :
'#1f1f1f'
var cssText = `top: 0; background: ${showBg};`
document.getElementById('app-refresh').style.cssText = cssText
}
}修改
[Blogroot]\themes\butterfly\layout\includes\additional-js.pug
,在文件底部添加以下内容,注意缩进。butterfly_v3.6.0
取消了缓存配置,转为完全默认,需要将{cache:theme.fragment_cache}
改为{cache: true}
:- 这里直接加就行
1
2if theme.pwa.enable
!=partial('includes/third-party/pwanotice', {}, {cache: true})
之后就可以了。(仅供个人使用)