关于hexo网上的绝大部分对markdown语法进行渲染的都是mathjax引擎,
但是mathjax实在是响应太慢了。
后来看到了链接[1],是针对next主题的,下载了一个next主题研究了下,发现主题里面并没有katex相关的东西,于是猜测一定程度上,katex无视主题。
下面说下在yelee主题[2]上的处理步骤:
npm install hexo-math --save
npm un hexo-renderer-marked --save
npm i hexo-renderer-markdown-it-plus --save
站点根目录下面的_config.yml:
math:
engine: katex
katex:
css: https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css
js: https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js
config:
# KaTeX config
throwOnError: false
errorColor: "#cc0000"
yelee主题下面的_config.yml
# Math Equations Render Support
math:
enable: true
per_page: false
#engine: mathjax
engine: katex
katex:
# Use 0.7.1 as default, jsdelivr as default CDN, works everywhere even in China
cdn: //cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css
#cdn: //cdn.jsdelivr.net/npm/katex@0.7.1/dist/katex.min.css
# CDNJS, provided by cloudflare, maybe the best CDN, but not works in China
#cdn: //cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css
copy_tex:
# See: https://github.com/KaTeX/KaTeX/tree/master/contrib/copy-tex
enable: true
copy_tex_js: //cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.js
copy_tex_css: //cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.css
hexo clean && hexo g && gulp && hexo d
(gulp是用来给hexo整体进行加速的,没安装和配置过gulp的可以去掉这个命令)
预览效果是:
https://appleyuchi.github.io/2019/06/12/A-new-post/
[1]https://jun-wang-2018.github.io/MyBlog/en/hexo-and-katex/