博客使用备忘录
写文章
2019.11.24更新!!: 多平台同步问题!!
-
使用前一定要先同步!!
- kali上:
git pull
- windows上:
git pull
orHexoSyn
- kali上:
-
hexo new 文章名
这一步后会在source\ _post\ 目录下生成相应的文章 -
进入相应目录
-
haroopad 文章名 &
保存 -
或者Typora打开文章,但是写完之后要注意图片同步问题
上传文章
同步图片不需要了hexoImgCp
-
hexo g
生成静态页面 -
hexo d
提交github -
上传本地 更新后的环境!
-
kali:
1
2
3git add .
git commit -m "kali提交说明: "
git push origin master -
windows:
1
bash HexoUpload
或者:
1
2
3git add .
git commit -m "Windows提交说明: "
git push origin master
-
图片保存
-
图片保存在 public/img 中 -
文章中引用: /img/xxx.png -
Typora配置中图片保存在/img/ (系统img目录)下,需要在同步一次图片到上传目录下hexoImgCp
2019.11.23更新
上述图片保存路径废弃,新的保存路径如下:
- 图片保存在 文章同目录下的与文章同名的文件夹内 (source/_post/xxx文件夹)
- 文章中引用: 文章名/图片名
- Typora配置中图片保存在 ./${filename} 下,不需要上述同步过程
2022.5.13更新
-
source/_data/butterfly.yml
配置文件优先级高于themes/Butterfly/_config.yml
-
修改博客背景图片等图片资源 放在
themes/Butterfly/source/img/
下 , hexo g后会把此目录下的文件拷贝到public/img/
中 -
新建
source/images
文件夹,主题配置文件source/_data/butterfly.yml
中的博客背景图片等图片资源也可放在此文件夹下,hexo g后会将此文件夹内容复制到public/images
文件夹 -
本地搜索使用xml格式对文章内容支持性不好,经常出现特殊字符导致的xml格式错误,所以改用JSON格式。修改Butterfly中的源码
themes/Butterfly/source/js/search/local-search.js
,修改如下: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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116$(function () {
var loadFlag = false // 预加载content.json
search(GLOBAL_CONFIG.localSearch.path)
loadFlag = true
$('a.social-icon.search').on('click', function () {
$('body').css('width', '100%')
$('body').css('overflow', 'hidden')
$('.search-dialog').animate({
}, function () {
$('.search-dialog').css({
'display': 'block',
'animation': 'titlescale 0.5s'
}),
300
})
$('#local-search-input input').focus()
$('.search-mask').fadeIn();
if (!loadFlag) {
search(GLOBAL_CONFIG.localSearch.path)
loadFlag = true
} // shortcut: ESC
document.addEventListener('keydown', function f(event) {
if (event.code === 'Escape') {
closeSearch()
document.removeEventListener('keydown', f)
}
})
})
var closeSearch = function () {
$('body').css('overflow', 'auto')
$('.search-dialog').animate({
}, function () {
$('.search-dialog').css({
'display': 'none'
})
})
$('.search-mask').fadeOut();
}
$('.search-mask, .search-close-button').on('click', closeSearch)
function search(path) {
$.ajax({
url: GLOBAL_CONFIG.root + path,
dataType: 'json',
success: function (xmlResponses) {
// get the contents from search data
var datas = $(xmlResponses).map(function () {
return {
title: this.title,
content: this.content,
url: this.url
}
}).get()
var $input = $('#local-search-input input') [0] //---- 添加结果区域----
$('#local-stats').append('<div class="search-result-list" id="resultDis"></div>')
$input.addEventListener('input', function () {
//var str = '<div class="search-result-list">'
//------清除展示区域-----
$('#resultDis').empty() //
var keywords = this.value.trim().toLowerCase().split(/[\s]+/) //$resultContent.innerHTML = ''
if (this.value.trim().length <= 0) {
$('.local-search-stats__hr').hide()
return
}
var count = 0 // 去除content中的<xxx> 和 图像内容
var regSContent = new RegExp('!\\[[^\\]]*\\]\\([^\\)]*\\)|<[^>]+>|top_img: /.*(png|jpg|gif)|cover: /.*(png|jpg|gif)', 'gi');
// perform local searching
datas.forEach(function (data) {
var isMatch = true
var dataTitle = data.title.trim().toLowerCase()
var dataContent = data.content.trim().replace(regSContent, '').toLowerCase() //去除<xxx>
var dataUrl = data.url
var indexTitle = - 1
var indexContent = - 1
var tmpDisplayContent = '' // only match artiles with not empty titles and contents
if (dataTitle !== '' || dataContent !== '') {
keywords.forEach(function (keyword, i) {
indexTitle = dataTitle.indexOf(keyword)
indexContent = dataContent.indexOf(keyword)
if (indexTitle < 0 && indexContent < 0) {
isMatch = false
} else {
if (indexContent < 0) {
indexContent = 0
}
}
})
} // show search results
if (isMatch) {
// 截取100长度的内容也展示出来,若只匹配了标题 则展示文章开头15个字符 ,对中间的关键词加粗处理
tmpDisplayContent = dataContent.substring(indexContent - 50, indexContent + 50)
keywords.forEach(function (keyword) {
var regS = new RegExp(keyword, 'gi');
tmpDisplayContent = tmpDisplayContent.replace(regS, '<mark style="color: white; background-color:green">' + keyword + '</mark>');
});
$('#resultDis').append('<div style="border-top: 1px solid #dddddd" class="local-search__hit-item">' +
'<a href="' + dataUrl + '" class="search-result-title">' +
'<strong>《' + dataTitle + '》:</strong> " ' + tmpDisplayContent + ' "' +
'</a>' +
'</div>'
)
count += 1
$('.local-search-stats__hr').show()
}
})
if (count === 0) {
str += '<div id="local-search__hits-empty">' + GLOBAL_CONFIG.localSearch.languages.hits_empty.replace(/\$\{query}/, this.value.trim()) +
'</div>'
}
$('#local-hits').append('<p>未搜索到相关结果</p>')
})
}
})
}
}) -
新建
themes/Butterfly/source/css/my_background.css
文件来更改博客背景渐变色
博客查看
- 可以 hexo server 然后在本地查看效果
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Rick!
评论