0%

Hexo-插件及配置

本地搜索

插件安装

在hexo根目录安装

1
npm install hexo-generator-searchdb --save
> 我安装完插件后,hexo就被卸载了,还要使用yarn upgrade重新安装一遍hexo,你也可以使用yarn add hexo-generator-searchdb命令安装插件

修改根目录下的_config.yml

1
2
3
4
5
search:
path: search.xml
field: post
format: html
limit: 10000
编辑主题配置文件,我是用的next主题
1
2
local_search:
enable: true
#### 出现的异常 当我点击搜索按钮时,会发生页面无限加载,问题是我的一篇文章中出现了非utf-8的文字,所以造成了xml报错,无法被读取.根据根目录下的search.xml出错信息,找到原文章删除特殊字符即可.

引用标签

1
2
3
{% asset_path slug %} #路径引用
{% asset_img slug [title] %} #图片引用
{% asset_link slug [title] %} #文件引用,用作下载链接

latex支持

卸载原有渲染器,安装hexo-renderer-kramed

1
2
yarn remove hexo-renderer-marked
yarn add hexo-renderer-kramed

修改next配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Math Equations Render Support
math:
enable: true

# 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

engine: mathjax
#engine: katex

# hexo-rendering-pandoc (or hexo-renderer-kramed) needed to full MathJax support.
mathjax:
cdn: https://cdn.bootcss.com/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML #问号后面的是引用配置
#cdn: //cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML

修改解析错误

这里的解析错误代表单行引用时要加四个反斜线才能正常换行

更换pandoc解码器

1
2
yarn remove hexo-renderer-marked
yarn add hexo-renderer-pandoc
恰饭,恰饭