主要参考vuepress-theme-reco设置math公式。
步骤
- 定位到博客的根目录下,安装库
1
| npm i markdown-it-texmath
|
- 安装
markdown-it
1
| npm install markdown-it --save
|
- 安装
katex
- 修改
.vuepress/config.js
文件
1
2
3
4
5
6
7
| markdown: {
lineNumbers: true,
anchor: { permalink: false },
toc: {includeLevel: [1,2]},
extendMarkdown: md => {
md.use(require('markdown-it-texmath'))
}
|
head
部分添加下面的代码:
1
2
3
4
5
| ['link', {"rel":'stylesheet', "href":'https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.css'}],
['link', {"rel":'stylesheet', "href":'https://gitcdn.xyz/cdn/goessner/markdown-it-texmath/master/texmath.css'}],
['script', {"src": 'https://github.com/markdown-it/markdown-it/blob/master/bin/markdown-it.js'}],
['script', {"src": 'https://gitcdn.xyz/cdn/goessner/markdown-it-texmath/master/texmath.js'}],
['script', {"src": 'https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.js'}]
|
- 更新提交后,就大功告成了。