本文转载自:xiholix博客
1. 使用Kramed代替 Marked
在工程目录下(即hexo init执行的那个目录下)执行以下命令安装Kramed
npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-kramed --save
然后将/node_modules/hexo-renderer-kramed/lib/renderer.js中的内容按如下方式修改:
更改前:
// Change inline math rule
function formatText(text) {
// Fit kramed's rule: $$ + \1 + $$
return text.replace(/`\$(.*?)\$`/g, '$$$$$1$$$$');
}
更改后:
// Change inline math rule
function formatText(text) {
return text;
}
2. 停止使用hexo-math,安装 hexo-renderer-mathjax
命令如下:
npm uninstall hexo-math --save
npm install hexo-renderer-mathjax --save
3. 更新 Mathjax 的 CDN 链接
将/node_modules/hexo-renderer-mathjax/mathjax.html中的CDN链接更改为下面的链接
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"></script>
4. 修改hexo的默认转义规则
打开/nodes_modules/marked/lib/marked.js文件对其进行如下几项修改
更改前
escape: /^\\([\\`*{}\[\]()#$+\-.!_>])/,
em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
更改后:
escape: /^\\([`*\[\]()# +\-.!_>])/,
em: /^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
5. 开启mathjax
在主题的_config.yml中添加(如果不存在)或修改(如果存在)mathjax配置
mathjax:
enable: true
6. 安装next主题并配置Next.Mist
在项目根目录执行如下git命令,安装Next主题
git clone https://github.com/iissnan/hexo-theme-next themes/next
cd themes/next
git pull
在根目录的_config.yml更改主题配置
theme: next
在themes/next下的_config.yml更改Mist配置
将
scheme: Muse
更改为
scheme: Mist
7. 网站底部加上访问量(使用busuanzi)
在themes/next里的_config.yml将busuanzi的统计打开
busuanzi_count:
# count values only if the other configs are false
enable: true
8.配置评论(使用Valine和Leancloud)
首先注册Leanclout账号注册链接,创建一个应用,并获取其appkey和appid
然后修改themes/next下的_config.yml的对应配置
valine:
enable: true
appid: # your leancloud application appid
appkey: # your leancloud application appkey
9.开启分享功能(jiathis)
编辑themes/next下的_config.yml
jiathis: true
##uid: Get this uid from http://www.jiathis.com/
#add_this_id:
10. 与github链接
首先将电脑的ssh公钥加入到github账号中,然后配置项目根目录下的_config.yml
deploy:
type: git
repository: git@github.com:usrname/username.github.io.git
branch: master
11. 配置搜索功能
在项目根目录执行如下命令安装相应组件
npm install hexo-generator-searchdb --save
修改站点配置文件,添加如下配置
search:
path: search.xml
field: post
format: html
limit: 10000
修改主题配置文件
local_search:
enable: true