搞了好几天终于把博客建起来了
现在开始罗列遇到的问题和解决方法
1.数学公式不加载
在_config.butterfly.yml
文件中选择katex
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| math: use: katex per_page: true hide_scrollbar: false
mathjax: enableMenu: true tags: none
katex: copy_tex: true
|
- 卸载hexo-renderer-marked
- 卸载hexo-renderer-kramed
cnpm i hexo-renderer-markdown-it --save
在hexo根目录_config.yml中配置
1 2 3
| markdown: plugins: - '@renbaoshuo/markdown-it-katex'
|
注意:一定要卸载掉hexo-renderer-marked和hexo-renderer-kramed才能使用
2.Markdown插入图片
_congig.yml
文件中45行左右位置
将false修改为true,这样子会新建一篇博客时随着markdown文件时新建一个目录。图片可以直接放在目录下。
markdown文件中调用图片可以直接使用markdown的调用方法,注意修改路径
下面的test博客中,test.png
路径为_post/test/test.png
1 2 3 4 5
| 正确加载写法:<img src="test.png" alt="测试" style="zoom: 25%;" /> 无法加载写法:<img src="./test/test.png" alt="测试" style="zoom: 25%;" />
正确加载写法: 无法加载写法:
|
虽然test.md和test.png不在同级目录,但是可以直接写图片名无需加前面的目录
3.网站信息卡片访问人数怎么关
一开始我找了半天以为是在aside侧栏的设置里面关闭,之后发现其实把统计彻底关了就行
在_config.butterfly.yml
文件中下面三个都设置为false
1 2 3 4 5
| # Busuanzi count for PV / UV in site busuanzi: site_uv: false site_pv: false page_pv: false
|
4.修改文章顶部图片高度
找到butterfly/source/css/_layout/post.styl
在开头加入
1 2 3
| #page-header &.post-bg height: 300px
|
其中height可以调节顶部图片高度
5.修改分类、标签等页面顶部图高度和文字高度
找到butterfly/source/css/_layout/head.styl
77行左右
1 2 3 4 5 6 7 8 9 10 11 12
| // page &.not-home-page height: 300px //这里修改顶部图高度
+maxWidth768() height: 280px
#page-site-info position: absolute top: 160px //这里修改顶部文字位置 padding: 0 10px width: 100%
|
6.h1-h6标题添加美化小风车后距离左侧太远?
我找了半天没找到在哪配置,那么我直接强行修改吧哈哈哈哈
source/css/custom.css
中添加:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| .container.post-content h1, .container.post-content h2, .container.post-content h3, .container.post-content h4, .container.post-content h5, .container.post-content h6 { padding-left: 15px!important; }
.container.post-content h1:hover, .container.post-content h2:hover, .container.post-content h3:hover, .container.post-content h4:hover, .container.post-content h5:hover, .container.post-content h6:hover { padding-left: 18px!important; color: #1d42a7; }
|
受不了辣,直接强行修改到左侧的距离
记得在inject里引入
1 2 3
| inject: head: - <link rel="stylesheet" href="/css/custom.css">
|
7.live2d不加载
live2d本地不加载
live2d要是在本地无法加载的话,那么大概率是因为模型不兼容问题。
如果使用了hexo-helper-live2d
的话,就无法使用model3格式的live2d文件,因为这个插件在几年前就停止更新了。现在大部分都是model3文件,所以我们需要使用另一款live2d插件:hexo-oh-my-live2d
1
| cnpm install hexo-oh-my-live2d
|
下载后看到配置文件:
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
| OhMyLive2d: enable: true CDN: /live2d/index.min.js option: libraryUrls: complete: https://registry.npmmirror.com/oh-my-live2d/latest/files/lib/complete.js cubism2: https://registry.npmmirror.com/oh-my-live2d/latest/files/lib/cubism2.js cubism5: https://registry.npmmirror.com/oh-my-live2d/latest/files/lib/cubism5.js menus:
mobileDisplay: true models: - path: /live2d/泉此方/泉此方.model3.json mobilePosition: [-10, 23] mobileScale: 0.1 mobileStageStyle: width: 180 height: 166 motionPreloadStrategy: NONE position: [20, 55] scale: 0.15 stageStyle: width: 250 height: 250 parentElement: document.body primaryColor: 'var(--btn-bg)' sayHello: false tips: style: width: 200 height: 120 left: calc(50% - 5px) top: -80px mobileStyle: width: 180 height: 70 left: calc(50% - 30px) top: -100px idleTips: interval: 15000 message: | function(){ return axios.get('https://v1.hitokoto.cn?c=i') .then(function (response) { return response.data.hitokoto ; }) .catch(function (error) { console.error(error); }); }
|
首先把自己的模型放在source中
只需要在models.path处换成自己模型中的model3文件路径即可
- 如果觉得舞台边上的按钮看着比较烦人,可以直接加入下面代码让舞台边上的按钮全部消失
1 2 3 4 5
| menus: items: | (defaultItems)=>{ return [] }
|
live2d云端不加载
非常的诡异啊,我在github.io访问的时候一切都很正常,但是我使用域名解析后,通过域名访问直接让live2d神秘消失了!
打开控制台一看
1 2 3
| https: Request Method: GET Status Code: 403 Forbidden
|
嚯嚯嚯,原来是国内域名访问不了镜像
那么就用最暴力的方法咯
- 直接提前下载好了镜像中的
index.min.js
文件
- 存放在
source/live2d
里
- 将
_config.yml
文件中下面内容进行修改:
1 2 3 4
| OhMyLive2d: enable: true CDN: /live2d/index.min.js
|
推送上去,还真行了o.O
8.加载页面等待时间过长
我开了一个加载动画,这个动画会在整个页面加载完成后才停下,live2d会导致加载很久,但是如果关闭的话,已进入页面所有图片全都显示空白,那么就…
限制他最多加载3s咯,这样子一般来说顶部图能加载好,而live2d进去慢慢加载也无所谓
themes\butterfly\layout\includes\loading
文件中26行左右
1 2
| preloader.initLoading() window.addEventListener('load', preloader.endLoading)
|
修改为
1 2 3 4 5 6 7 8
| preloader.initLoading() const loadingTimeout = setTimeout(preloader.endLoading, 3000);
// 限制最多加载3s window.addEventListener('load', () => { clearTimeout(loadingTimeout); preloader.endLoading(); });
|