跳到主要内容

数学公式加入

我发现kuizuo的博客框架没加入docusaurus的公式

给他加一手

为了开启KaTeX,要 安装 mathjaxremark-mathrehype-katex 插件

npm install --save remark-math@3 rehype-katex@5 [email protected]
npm install mathjax

在present里加上

remarkPlugins: [require('remark-math')],
rehypePlugins: [require('rehype-katex')],

像这样

image-20230504153946157

最后,找到stylesheets,把kuizuo留下的空白填满即可

  stylesheets: [
{
href: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css',
type: 'text/css',
integrity:
'sha384-MlJdn/WNKDGXveldHDdyRP1R4CTHr3FeuDNfhsLPYrq2t0UBkUdK2jyTnXPEK1NQ',
crossorigin: 'anonymous',
},
],

最后可能长这样

const math = require('remark-math');

async function createConfig() {
return {
title: 'Docusaurus',
tagline: 'Build optimized websites quickly, focus on your content',
presets: [
[
'@docusaurus/preset-classic',
{
docs: {
path: 'docs',
remarkPlugins: [require('remark-math')],
rehypePlugins: [require('rehype-katex')],
},
},
],
],
stylesheets: [
{
href: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css',
type: 'text/css',
integrity:
'sha384-MlJdn/WNKDGXveldHDdyRP1R4CTHr3FeuDNfhsLPYrq2t0UBkUdK2jyTnXPEK1NQ',
crossorigin: 'anonymous',
},
],
};
}

module.exports = createConfig;