Skip to content

Commit 3636a8e

Browse files
committed
feat: support math equations
1 parent 6dea9e0 commit 3636a8e

File tree

3 files changed

+191
-2
lines changed

3 files changed

+191
-2
lines changed

docusaurus.config.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { themes as prismThemes } from 'prism-react-renderer'
22
import type { Config } from '@docusaurus/types'
33
import type * as Preset from '@docusaurus/preset-classic'
4+
import remarkMath from 'remark-math'
5+
import rehypeKatex from 'rehype-katex'
46

57
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
68

@@ -46,6 +48,8 @@ const config: Config = {
4648
},
4749
docs: {
4850
routeBasePath: '/',
51+
remarkPlugins: [remarkMath],
52+
rehypePlugins: [rehypeKatex],
4953
sidebarItemsGenerator: async (args) => {
5054
const { defaultSidebarItemsGenerator } = args
5155
const items = await defaultSidebarItemsGenerator(args)
@@ -67,7 +71,15 @@ const config: Config = {
6771
} satisfies Preset.Options
6872
]
6973
],
70-
74+
stylesheets: [
75+
{
76+
href: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css',
77+
type: 'text/css',
78+
integrity:
79+
'sha384-odtC+0UGzzFL/6PNoE8rX/SPcQDXBJ+uRepguP4QkPCm2LBxH3FA3y+fKSiJ+AmM',
80+
crossorigin: 'anonymous'
81+
}
82+
],
7183
themeConfig: {
7284
colorMode: {
7385
disableSwitch: true

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"prism-react-renderer": "^2.3.0",
2727
"rc-tooltip": "^6.4.0",
2828
"react": "^19.0.0",
29-
"react-dom": "^19.0.0"
29+
"react-dom": "^19.0.0",
30+
"rehype-katex": "^7.0.1",
31+
"remark-math": "^6.0.0"
3032
},
3133
"devDependencies": {
3234
"@docusaurus/module-type-aliases": "3.8.1",

pnpm-lock.yaml

Lines changed: 175 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)